* @copyright Copyright (c) 2010, ConsultorPC * @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html * @link http://smartclientphp.com/ * @since Version 0.1 * @filesource */ /** * Smart Client Search Form Helper * */ class ScSearchForm extends ScForms { /** * * Create * * Create the dynamic form * * @param mixed $data If string, it must be the id of the form. If array, them we will loop through it * @param string $action Action of the form * @param array $options Additional options * @return string * */ public function create( $data , $action = '' , $options = '' ) { $newForm = array(); // Check if it is an array if ( is_array( $data ) ) { $newForm = $data; } else { // Add vars to the new form $newForm['ID'] = $data; $newForm['action'] = $action; $newForm['fields'] = $this->_fields; // Set the default value for canSubmit if ( !isset( $options['canSubmit'] ) ) { $options['canSubmit'] = true; } // Set the default value for saveOnEnter if ( !isset( $options['saveOnEnter'] ) ) { $options['saveOnEnter'] = true; } // Check if options is array and do the loop if ( is_array( $options ) ) { foreach ( $options as $name => $value ) { $newForm[$name] = $value; } } } // Encode data $dataEncoded = $this->encode( $newForm ); // Generate js code $js = 'isc.SearchForm.create( '. $dataEncoded .' );'; // Add script tag $js = $this->addScriptTags( $js ); return $js; } } ?>