Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony] jak dołączyć formularz na stronę ?
nieraczek
post
Post #1





Grupa: Zarejestrowani
Postów: 405
Pomógł: 6
Dołączył: 12.01.2007

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


Jak wyświetlić na stronie formularz, bo pojawia mi się błąd ?

W actions.class.php mam:
  1. <?php
  2. public function executeStronka(sfWebRequest $request)
  3.  {
  4.    $this->form = new FormularzJedenForm();
  5.  }
  6. ?>


W stronkaSuccess.php mam:
  1. <div id="job">
  2.  
  3. Formularz:
  4. <?php
  5. include_partial('lib/form/FormularzJeden')
  6. ?>
  7.  
  8. </div>


Nie bardzo rozumiem funkcji include_partial(), co mam w nią wpisać ? Dołącza ona zawartość pliku, ale jakoś nie do końca rozumiem, bo często ma jeszcze tablice array().


Poza tym mam jeszcze plik FormularzJedenForm.class.php - umieściłem go w katalogu sf_sandbox\lib\form - jest to chyba właściwe miejsce, bo są tu umieszczone formularze automatycznie wygenerowane przez Symfony.
  1. <?php
  2. class FormularzJedenForm extends sfForm
  3. {
  4.  public function configure()
  5.  {
  6.      $this->setWidgets(array(
  7.      'email'   => new sfWidgetFormInput(),
  8.      'message' => new sfWidgetFormTextarea(),
  9.    ));
  10.  
  11.    $this->setValidators(array(
  12.      'email'   => new sfValidatorEmail(),
  13.      'message' => new sfValidatorString(array('max_length' => 255)),
  14.    ));
  15.  
  16.  }
  17. }
  18. ?>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nieraczek
post
Post #2





Grupa: Zarejestrowani
Postów: 405
Pomógł: 6
Dołączył: 12.01.2007

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


Znalazłem opis tworzenia i wyświetlania formularza na stronie symfony (w tutorialu tego nie było). Tylko ja chciałbym wstawić formularz na stronę a nie wyświetlać go samego.
W konsoli wydałem polecenie:
php symfony generate:module fronted formularz1

I teraz mam w frontend/modules folder formularz1 a w nim:
actions/actions.class.php:
  1. <?php
  2. class formularz1Actions extends sfActions
  3. {
  4. /**
  5.   * Executes index action
  6.   *
  7.   * @param sfRequest $request A request object
  8.   */
  9.  public function executeIndex(sfWebRequest $request)
  10.  {
  11.    $this->forward('default', 'module');
  12.  }
  13. }
  14. ?>


oraz templates/indexSuccess.php gdzie dodałem to co pisaliście:
  1. <?php echo $form ?>



Natomiast w frontend/modules w folderze job/actions w actions.class.php funkcje:
  1. <?php
  2. public function executeStronka(sfWebRequest $request)
  3.  {
  4.    
  5.  }
  6. ?>


W frontend/modules w folderze job/templates w stronkaSuccess.php mam:
  1. <?php
  2. Formularz:
  3. ?>


i na tej stronie chciałbym wyświetlić formularz formularz1 - jak to zrobić ?
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: 28.12.2025 - 01:11