public function post_multi_page_example_two() { $fields = array('street_address', 'suite_number', 'favorite_foods'); if (!ExampleForm::is_valid($fields)) { return Redirect::back()->with_input()->with_errors(ExampleForm::$validation); } ExampleForm::save_input($fields); return Redirect::to_route('form_examples', array('multi_page_example_review')); }
* @param $item * @return string */ public function dtgPerson_BalanceRender($item) { $val = $item->Budget - $item->Spent; if ($val < 0) { return '(' . number_format(-$val) . ')'; } else { return number_format($val); } } /** * Style the number in the column. All number columns will use the amount class. If the number is negative, make * the cell red. * * @param $item * @return mixed */ public function dtgPerson_BalanceAttributes($item) { $ret['class'] = 'amount'; $val = $item->Budget - $item->Spent; if ($val < 0) { $ret['style'] = 'color:red'; } return $ret; } } ExampleForm::Run('ExampleForm');
$this->flaSample->TemporaryUploadPath = __QCUBED_UPLOAD__; $this->flaSample->ClickToView = true; // NOTICE: If we are wanting users to immediately "click to view" files that are uploaded directly to the docroot, // we MUST take security precautions to prevent users from executing arbitrary code on the system. // Precautions could be: defining / overriding our own GetWebUrl() method in QFileAsset or // limiting the "types" of files that a user could upload. We will go ahead and do this limiting here. $this->flaSample->FileAssetType = QFileAssetType::Image; // Feel free to uncomment this yourself, but note that you can pre-define the File property. // Notice how the path is an absolute path to a file. // Also notice that the file doesn't even need to be in the docroot. // $this->flaSample->File = __DOCROOT__ . __IMAGE_ASSETS__ . '/calendar.png'; // Add Styling $this->flaSample->CssClass = 'file_asset'; $this->flaSample->imgFileIcon->CssClass = 'file_asset_icon'; $this->lblMessage = new QLabel($this); $this->lblMessage->Text = 'Click on the button to change this message.'; // The "Form Submit" Button -- notice how the form is being submitted via AJAX, even though we are handling // File Uploads on the form. $this->btnButton = new QButton($this); $this->btnButton->Text = 'Click Me'; $this->btnButton->AddAction(new QClickEvent(), new QAjaxAction('btnButton_Click')); $this->btnButton->CausesValidation = true; } protected function btnButton_Click($strFormId, $strControlId, $strParameter) { $this->lblMessage->Text = 'Thanks for uploading the file: ' . $this->flaSample->FileName . ". File size: " . $this->flaSample->Size . " bytes"; } } // And now run our defined form ExampleForm::Run('ExampleForm', 'file_asset.tpl.php');
<p> Street Address: {{ ExampleForm::get( 'street_address', 'none entered' ) }} </p> @if( ExampleForm::has( 'suite_number' ) ) <p> Suite / Apt #: {{ ExampleForm::get( 'suite_number' ) }} </p> @endif <p> Status: {{ ExampleForm::has( 'status' ) ? ExampleForm::$status[ExampleForm::get( 'status' )] : 'none selected' }} </p> <p> Favorite Foods: <?php $foods = ExampleForm::old('favorite_foods', array()); // workaround for blade forelse bug that i only just now found ?> @forelse( $foods as $food_id ) {{ ExampleForm::$foods[$food_id] }}<br /> @empty No foods selected. @endforelse </p> {{ HTML::link_to_route( 'form_examples', 'Make Changes', array( 'multi_page_example_one' ) ) }} {{ HTML::link_to_route( 'form_examples', 'Return to Examples Page', array( 'index' ) ) }}
<?php ini_set('display_errors', 1); // Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR, array('../library', get_include_path()))); // Autoloader require 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->registerNamespace('EasyBib'); // objects require 'ExampleForm.php'; $view = new Zend_View(); $form = new ExampleForm(); $form->setView($view); // form config $form->setMethod('POST'); $form->setAction('DecoratorExample.php'); $form->setAttrib('id', 'testForm'); $form->setAttrib('class', 'well'); if (!empty($_POST)) { $form->isValid($_POST); $form->getElement('email')->addError('test'); } ?> <!DOCTYPE html> <html> <head> <title>TestForm</title> <!-- <link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.3.0/bootstrap.min.css"> --> <link rel="stylesheet" href="css/bootstrap.min.css"> <link rel="stylesheet" href="css/bootstrap-responsive.min.css">
<?php include 'ExampleForm.php'; if (!isset($_POST)) { throw new Exception("No fue recibido ningún POST"); } else { header('Content-Type: text/html; charset=utf-8'); $formObject = new ExampleForm(); $formObject->load($_POST); echo "Validar formulario <br>"; var_dump($formObject->validate()); echo "Errores encontrados <br>"; var_dump($formObject->getErrors()); echo "Field1: {$formObject->field1} <br>"; echo "Field2: {$formObject->field2} <br>"; echo "Field3: {$formObject->field3} <br>"; echo "Field4: {$formObject->field4} <br>"; echo "Field5: {$formObject->field5} <br>"; }
require __INCLUDES__ . '/examples/examples.inc.php'; // Define the Qform with all our Qcontrols class ExampleForm extends ExamplesBaseForm { // Local declarations of our Qcontrols protected $lblMessage; protected $btnButton; // Initialize our Controls during the Form Creation process protected function Form_Create() { // Define the Label $this->lblMessage = new QLabel($this); $this->lblMessage->Text = 'Click the button to change my message.'; // Define the Button $this->btnButton = new QButton($this); $this->btnButton->Text = 'Click Me!'; // Add a Click event handler to the button -- the action to run is an AjaxAction. // The AjaxAction names a PHP method (which will be run asynchronously) called "btnButton_Click" $this->btnButton->AddAction(new QClickEvent(), new QAjaxAction('btnButton_Click')); } // The "btnButton_Click" Event handler protected function btnButton_Click($strFormId, $strControlId, $strParameter) { $this->lblMessage->Text = 'Hello, world!'; } } // Run the Form we have defined // We will explicitly specify an alternate filepath for the HTML template file. Note // that this filepath is relative to the path of this PHP script. ExampleForm::Run('ExampleForm', 'some_template_file.tpl.php');