Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SF][Symfony] sfFormExtraPlugin nie działa.
tOm-i
post
Post #1





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 3.05.2005

Ostrzeżenie: (0%)
-----


Walczę z tym pluginem od jakiegoś czasu konkretnie z częścią dotyczącą "Autocomplete"
Min, w tym wątku.
W końcu się wkurzyłem i zrobiłem dokładnie tak jak TU.
I też nie działa.
Może po prostu nie mam czegoś w php5 wkompilowane lub inny brak tego typu ?

Dodam, że napeno dobrze linkuje w tej częsci
  1. // apps/frontend/modules/article/templates/_form.php
  2. <?php use_javascript('/sfFormExtraPlugin/js/jquery.autocompleter.js') ?>
  3. <?php use_stylesheet('/sfFormExtraPlugin/css/jquery.autocompleter.css') ?>
  4.  
  5. <!-- ... -->



będę wdzięczy za pomoc.




Ten post edytował tOm-i 21.08.2009, 10:47:25
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
tOm-i
post
Post #2





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 3.05.2005

Ostrzeżenie: (0%)
-----


  1. symfony init-project test


w Database.yml ustawiłem parametry BD.
nastepnie:

  1. symfony propel:build-all
  2. symfony init-app frontend
  3. symfony propel:generate-module frontend article DemoArticle



dodaje:

CODE
// lib/form/DemoArticleForm.class.php
$this->widgetSchema['author_id']->setOption('renderer_class', 'sfWidgetFormPropelJQueryAutocompleter');
$this->widgetSchema['author_id']->setOption('renderer_options', array(
'model' => 'DemoAuthor',
'url' => $this->getOption('url'),
));

public function executeNew(sfWebRequest $request)
{
$this->form = new DemoArticleForm($article, array('url' => $this->getController()->genUrl('article/ajax')));
}

// apps/frontend/modules/article/actions/actions.class.php
public function executeAjax($request)
{
$this->getResponse()->setContentType('application/json');
$authors = DemoAuthorPeer::retrieveForSelect($request->getParameter('q'), $request->getParameter('limit'));
return $this->renderText(json_encode($authors));
}
class DemoAuthorPeer extends BaseDemoAuthorPeer
{
static public function retrieveForSelect($q, $limit)
{
$criteria = new Criteria();
$criteria->add(DemoAuthorPeer::NAME, '%'.$q.'%', Criteria::LIKE);
$criteria->addAscendingOrderByColumn(DemoAuthorPeer::NAME);
$criteria->setLimit($limit);
$authors = array();
foreach (DemoAuthorPeer::doSelect($criteria) as $author)
{
$authors[$author->getId()] = (string) $author;
}
return $authors;
}
}
// apps/frontend/modules/article/templates/_form.php
<?php use_javascript('/sfFormExtraPlugin/js/jquery.autocompleter.js') ?>
<?php use_stylesheet('/sfFormExtraPlugin/css/jquery.autocompleter.css') ?>

Dostaje błąd:

  1. Notice: Undefined variable: article in /home/sfprojects/test/apps/frontend/modules/article/actions/actions.class.php on line 20


wiec w lini:

  1. $this->form = new DemoArticleForm($article, array('url' => $this->getController()->genUrl('article/ajax')));


daje:

  1. $this->form = new DemoArticleForm(new DemoArticle(), array('url' => $this->getController()->genUrl('article/ajax')));


dostaje blad:
  1. Fatal error: Class 'sfWidgetFormPropelJQueryAutocompleter' not found in /usr/share/php/symfony/widget/sfWidgetFormChoice.class.php on line 126

Bo zapomniełem zainstalować pluginu
wiec:

  1. symfony plugin:install sfFormExtraPlugin


i
  1. symfony cache:clear


nastepnie blad:
  1. 500 | Internal Server Error | RuntimeException
  2. Class "DemoAuthor" must implement a "__toString" method to be rendered in a "sfWidgetFormPropelJQueryAutocompleter" widget

wiec dodaje metody __toString

CODE
class DemoAuthor extends BaseDemoAuthor
{
public function __toString()
{
return $this->getName();
}
}


class DemoCategory extends BaseDemoCategory
{
public function __toString()
{
return $this->getName();
}
}


class DemoTag extends BaseDemoTag
{
public function __toString()
{
return $this->getName();
}
}


w bazie w demo_author dodaje 2 wpisy:
xtest 1
xtest 2


na końcu dałem jeszcze:

  1. symfony plugin:publish-assets



i nadal nie działa


w article/new mam
CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="shortcut icon" href="/favicon.ico" />
<script type="text/javascript" src="/sfFormExtraPlugin/js/jquery.autocompleter.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="/css/main.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/sfFormExtraPlugin/css/jquery.autocompleter.css" />
</head>

<body>
<h1>New Article</h1>


<form action="/article/create" method="post" >
<table>
<tfoot>
<tr>
<td colspan="2">
<input type="hidden" name="demo_article[id]" id="demo_article_id" /> &nbsp;<a href="/article">Cancel</a>

<input type="submit" value="Save" />
</td>
</tr>
</tfoot>
<tbody>
<tr>
<th><label for="demo_article_author_id">Author id</label></th>
<td>

<input type="hidden" name="demo_article[author_id]" id="demo_article_author_id" /><input type="text" name="autocomplete_demo_article[author_id]" value="" id="autocomplete_demo_article_author_id" /><script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#autocomplete_demo_article_author_id")
.autocomplete('/article/ajax', jQuery.extend({}, {
dataType: 'json',
parse: function(data) {
var parsed = [];
for (key in data) {
parsed[parsed.length] = { data: [ data[key], key ], value: data[key], result: data[key] };
}
return parsed;
}
}, { }))
.result(function(event, data) { jQuery("#demo_article_author_id").val(data[1]); });
});
</script> </td>
</tr>
<tr>
<th><label for="demo_article_status">Status</label></th>
<td>

......CUT


article/ajax daje mi plik z danymi z bazy czyli:
  1. {"2":"xtest 1","1":"xtest 2"}


tak to wygląda...


Ten post edytował tOm-i 21.08.2009, 10:54:25
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 8.10.2025 - 10:38