PD
Formulário passo a passo
Fechado
Neste exemplo, vamos demonstrar um formulário passo a passo. Este formulário possui um objeto notebook com três páginas. O usuário pode navegar pelas páginas usando botões próximo e anterior. Cada página do notebook possui dois campos. A página 1 tem um botão próximo conectado ao método onStep2(). A página 2 possui dois botões: próximo, conectado ao método onStep1(); e próximo, conectado ao método onStep3(). A última página possuio dois botões: anterior, conectado ao método onStep2(); e "Save", conectado ao método onSavE(). Cada método mantém os dados do formulário e altera a página atual do notebook, por meio do método setCurrentPage() da classe TNotebook. O método onSave() simplesmente exibe os dados do formulário, que irá retornar a informação de todos os seis campos.
<?php/** * StepbyStepForm report * * @version 1.0 * @package samples * @subpackage tutor * @author Pablo Dall'Oglio * @copyright Copyright (c) 2006-2011 Adianti Solutions Ltd. (http://www.adianti.com.br) * @license http://www.adianti.com.br/framework-license */class StepbyStepForm extends TPage{ private $notebook; private $form; private $page1; private $page2; private $page3; /** * Class constructor * Creates the page and the registration form */ function __construct() { parent::__construct(); // create the notebook $this->notebook = new TNotebook(340, 100); // create the form $this->form = new TForm; // creates the notebook page $page1 = new TTable; $page2 = new TTable; $page3 = new TTable; // add the notebook inside the form $this->form->add($this->notebook); // adds the notebook page $this->notebook->appendPage('Page 1', $page1); $this->notebook->appendPage('Page 2', $page2); $this->notebook->appendPage('Page 3', $page3); // create the form fields $field1 = new TEntry('field1'); $field2 = new TEntry('field2'); $field3 = new TEntry('field3'); $field4 = new TEntry('field4'); $field5 = new TEntry('field5'); $field6 = new TEntry('field6'); // add a row for one field $row=$page1->addRow(); $row->addCell(new TLabel('Field 1:')); $cell = $row->addCell( $field1 ); // add a row for one field $row=$page1->addRow(); $row->addCell(new TLabel('Field 2:')); $cell = $row->addCell( $field2 ); // creates the action button $button1=new TButton('action1'); $button1->setAction(new TAction(array($this, 'onStep2')), 'Next'); $button1->setImage('ico_next.png'); $row=$page1->addRow(); $row->addCell( $button1 ); // add a row for one field $row=$page2->addRow(); $row->addCell(new TLabel('Field 3:')); $cell = $row->addCell( $field3 ); // add a row for one field $row=$page2->addRow(); $row->addCell(new TLabel('Field 4:')); $cell = $row->addCell( $field4 ); // creates the action button $button2=new TButton('action2'); $button2->setAction(new TAction(array($this, 'onStep1')), 'Previous'); $button2->setImage('ico_previous.png'); $row=$page2->addRow(); $row->addCell( $button2 ); // creates the action button $button3=new TButton('action3'); $button3->setAction(new TAction(array($this, 'onStep3')), 'Next'); $button3->setImage('ico_next.png'); $row->addCell( $button3 ); // add a row for one field $row=$page3->addRow(); $row->addCell(new TLabel('Field 5:')); $cell = $row->addCell( $field5 ); // add a row for one field $row=$page3->addRow(); $row->addCell(new TLabel('Field 6:')); $cell = $row->addCell( $field6 ); // creates the action button $button4=new TButton('action4'); $button4->setAction(new TAction(array($this, 'onStep2')), 'Previous'); $button4->setImage('ico_previous.png'); $row=$page3->addRow(); $row->addCell( $button4 ); $button5=new TButton('save'); $button5->setAction(new TAction(array($this, 'onSave')), 'Save'); $button5->setImage('ico_save.png'); $row->addCell( $button5 ); // define wich are the form fields $this->form->setFields(array($field1, $field2, $field3, $field4, $field5, $field6, $button1, $button2, $button3, $button4, $button5)); // add the form inside the page parent::add($this->form); } function onStep1() { $this->notebook->setCurrentPage(0); $this->form->setData($this->form->getData()); } function onStep2() { $this->notebook->setCurrentPage(1); $this->form->setData($this->form->getData()); } function onStep3() { $this->notebook->setCurrentPage(2); $this->form->setData($this->form->getData()); } function onSave() { $this->notebook->setCurrentPage(2); $this->form->setData($this->form->getData()); new TMessage('info', json_encode($this->form->getData())); }}?>
Olá Pablo,
É possível fazer um formulário do tipo Wizard como este no link abaixo:
authenticgoods.co/wrapbootstrap/themes/neuboard-v1.4.1/HTML_full_ver
?
Abs,
www.adianti.com.br/framework_files/tutor/index.php?class=StaticMulti
Só trocar o CSS