当前位置: 首页>>代码示例>>PHP>>正文


PHP HTML_QuickForm2::validate方法代码示例

本文整理汇总了PHP中HTML_QuickForm2::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm2::validate方法的具体用法?PHP HTML_QuickForm2::validate怎么用?PHP HTML_QuickForm2::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTML_QuickForm2的用法示例。


在下文中一共展示了HTML_QuickForm2::validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: storeValues

 /**
  * Stores the form values (and validation status) is session container
  *
  * @param    bool    Whether to store validation status
  */
 public function storeValues($validate = true)
 {
     $this->populateFormOnce();
     $container = $this->getController()->getSessionContainer();
     $id = $this->form->getId();
     $container->storeValues($id, (array) $this->form->getValue());
     if ($validate) {
         $container->storeValidationStatus($id, $this->form->validate());
     }
     return $container->getValidationStatus($id);
 }
开发者ID:N3X15,项目名称:ATBBS-Plus,代码行数:16,代码来源:Page.php

示例2: Key

	$rcpriv=$fsCaptcha->addElement('text','txtCPrivate',array(),array('label'=>'reCaptcha Private Key (<a href="'.$recaptchaurl.'">Get One</a>):'));
	$mhpub=$fsCaptcha->addElement('text','txtMHPublic',	array(),array('label'=>'Mailhide Public Key (<a href="http://mailhide.recaptcha.net/apikey">Get One</a>, different from recaptcha):'));
	$mhpriv=$fsCaptcha->addElement('text','txtMHPrivate',	array(),array('label'=>'Mailhide Private Key (<a href="http://mailhide.recaptcha.net/apikey">Get One</a>):'));
	
	$rcpub->addRule('required','Field required.');
	$rcpriv->addRule('required','Field required.');
	$mhpub->addRule('required','Field required.');
	$mhpriv->addRule('required','Field required.');
	*/
	
	$fsSubmit = $form->addElement('fieldset')->setLabel('Create Config');
	
	$fsSubmit->addElement('submit',null,array(),array('label'=>'Finish config and move on to Step 2'));


	if(!$form->validate())
	{
		include('installheader.php');
		include(LIBD.'output.php');
		/*?.>
		<p><b>BEFORE CONTINUING, GO TO <a href="<?=$recaptchaurl?>">RECAPTCHA</a> AND GET API KEY FOR BOTH RECAPTCHA ITSELF AND MAILHIDE! ITS FREE OF CHARGE AND REQUIRED.</b></p>
		<.?(*/
		Output::RenderQF2($form);
	} else {
		$_SESSION['allowNewAdminAcct']=true;
		include('installheader.php');
		include(LIBD.'db.php');
		include(LIBD.'output.php');
		$values=$form->getValue();
		define('ADODB_PREFIX',$values['txtSQLPrefix']);
		define('THISDIR',$values['txtSitePath']);
开发者ID:N3X15,项目名称:ATBBS-Plus,代码行数:31,代码来源:index.php

示例3: testValidateChecksWhetherFormIsSubmitted

 public function testValidateChecksWhetherFormIsSubmitted()
 {
     $form1 = new HTML_QuickForm2('notrack', 'post');
     $this->assertFalse($form1->validate());
     $form2 = new HTML_QuickForm2('track', 'post');
     $this->assertTrue($form2->validate());
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:7,代码来源:QuickForm2Test.php

示例4: read_preset_form

 /**
  * read_preset_form generates a quickform-object to choose the announcement-preset,
  * if validated redirect to announcement.php?id=new&cid=$id
  * 
  * @param object $calendar the actual calendarentry
  * @return object quickform-object to choose the preset, if validated redirect to new announcement
  */
 private function read_preset_form(&$calendar)
 {
     // check sort or from/to
     $sort = $from = $to = '';
     if ($this->get('sort') !== false) {
         $sort = "&sort=" . $this->get('sort');
     }
     if ($this->get('from') !== false) {
         $from = "&from=" . $this->get('from');
     }
     if ($this->get('to') !== false) {
         $to = "&to=" . $this->get('to');
     }
     // form-object
     $form = new HTML_QuickForm2('choose_preset_' . $calendar->get_id(), 'post', array('name' => 'choose_preset_' . $calendar->get_id(), 'action' => 'calendar.php?id=listall' . $sort . $from . $to));
     // add selectfield
     $select = $form->addSelect('preset', array());
     $options = array(0 => parent::lang('class.CalendarView#read_preset_form#select#choosePreset'));
     $options = $options + Preset::read_all_presets('calendar');
     $select->loadOptions($options);
     $select->addRule('callback', parent::lang('class.CalendarView#read_preset_form#rule#select'), array($this, 'callback_check_select'));
     // add submit
     $submit = $form->addSubmit('submit', array('value' => parent::lang('class.CalendarView#read_preset_form#select#submit')));
     // validate
     if ($form->validate()) {
         // get data
         $data = $form->getValue();
         // insert preset_id in calendar-entry
         $update = array('preset_id' => $data['preset']);
         $calendar->update($update);
         $calendar->write_db('update');
         // redirect to listall
         header('Location: calendar.php?id=listall' . $sort . $from . $to);
         exit;
     } else {
         return $form;
     }
 }
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:45,代码来源:class.CalendarView.php

示例5: validate

 public function validate()
 {
     $res = $this->isSubmitted() && parent::validate();
     if ($res) {
         $rules = [];
         $names = [];
         if ($this->validator_rules) {
             foreach ($this->validator_rules as $f => $element_rules) {
                 $name = LaraForm::getNameFromDot($f);
                 $elements = $this->getElementsByName($name);
                 if (count($elements)) {
                     $rules[$f] = $element_rules;
                     $names[$f] = '"' . Arr::get($elements, 0)->getLabel() . '"';
                 }
             }
             $validator = \Validator::make($this->getValue(), $rules, $this->validator_messages, $names);
             if ($validator->fails()) {
                 $errors = [];
                 foreach ($validator->errors()->toArray() as $k => $v) {
                     Arr::set($errors, $k, Arr::get($v, 0));
                 }
                 //dd($validator->errors()->toArray(), $errors);
                 $this->setErrors($errors);
                 $res = false;
             }
         }
     }
     return $res;
 }
开发者ID:larakit,项目名称:lk,代码行数:29,代码来源:LaraForm.php

示例6: edit

 /**
  * edit edits the entry
  * 
  * @return string html-string
  */
 private function edit()
 {
     // smarty-templates
     $sD = new JudoIntranetSmarty();
     // check rights
     if (Rights::check_rights($this->get('cid'), 'calendar')) {
         // check cid and pid given
         if ($this->get('cid') !== false && $this->get('pid') !== false) {
             // check cid and pid exists
             if (Calendar::check_id($this->get('cid')) && Preset::check_preset($this->get('pid'), 'calendar')) {
                 // pagecaption
                 $this->tpl->assign('pagecaption', parent::lang('class.AnnouncementView#page#caption#edit'));
                 // prepare return
                 $return = '';
                 // get preset
                 $preset = new Preset($this->get('pid'), 'calendar', $this->get('cid'));
                 // get fields
                 $fields = $preset->get_fields();
                 // formular
                 $form = new HTML_QuickForm2('edit_announcement', 'post', array('name' => 'edit_announcement', 'action' => 'announcement.php?id=edit&cid=' . $this->get('cid') . '&pid=' . $this->get('pid')));
                 // values
                 $datasource = array();
                 foreach ($fields as $field) {
                     // read values
                     $field->read_value();
                     // check type
                     if ($field->get_type() == 'text') {
                         // check defaults
                         $datasource['calendar-' . $field->get_id()]['manual'] = '';
                         $datasource['calendar-' . $field->get_id()]['defaults'] = 0;
                         if ($field->get_value() == '') {
                             $datasource['calendar-' . $field->get_id()]['defaults'] = 'd' . $field->get_defaults();
                         } else {
                             $datasource['calendar-' . $field->get_id()]['manual'] = $field->get_value();
                         }
                     } elseif ($field->get_type() == 'dbhierselect') {
                         // explode value
                         list($v_first, $v_second) = explode('|', $field->get_value(), 2);
                         // set values
                         $datasource['calendar-' . $field->get_id()][0] = $v_first;
                         $datasource['calendar-' . $field->get_id()][1] = $v_second;
                     } elseif ($field->get_type() == 'dbselect') {
                         // check multiple
                         if (strpos($field->get_value(), '|') !== false) {
                             // separate value
                             $values = explode('|', $field->get_value());
                             foreach ($values as $i => $value) {
                                 $datasource['calendar-' . $field->get_id()][$i] = $value;
                             }
                         } else {
                             $datasource['calendar-' . $field->get_id()] = $field->get_value();
                         }
                     } else {
                         $datasource['calendar-' . $field->get_id()] = $field->get_value();
                     }
                 }
                 $form->addDataSource(new HTML_QuickForm2_DataSource_Array($datasource));
                 // renderer
                 $renderer = HTML_QuickForm2_Renderer::factory('default');
                 $renderer->setOption('required_note', parent::lang('class.AnnouncementView#entry#form#requiredNote'));
                 // generate field-quickform and add to form
                 foreach ($fields as $field) {
                     // generate quickform
                     $field_id = $field->read_quickform(array(), true);
                     // check $field_id
                     if ($field_id != '' && $field->get_type() == 'date') {
                         // smarty
                         $sD->assign('elementid', $field_id . '-0');
                         $sD->assign('dateFormat', 'yy-mm-dd');
                         $sD->assign('dateValue', $field->get_value());
                         $this->add_jquery($sD->fetch('smarty.js-datepicker.tpl'));
                     }
                     // add to form
                     $form->appendChild($field->get_quickform());
                 }
                 // submit-button
                 $form->addSubmit('submit', array('value' => parent::lang('class.AnnouncementView#edit#form#submitButton')));
                 // validate
                 if ($form->validate()) {
                     // get calendar
                     $calendar = new Calendar($this->get('cid'));
                     // prepare marker-array
                     $announcement = array('version' => date('dmy'));
                     // get data
                     $data = $form->getValue();
                     // insert values
                     foreach ($fields as $field) {
                         // values to db
                         $field->value($data[$field->get_table() . '-' . $field->get_id()]);
                         $field->write_db('update');
                     }
                     // add calendar-fields to array
                     $calendar->add_marks($announcement);
                     // add field-names and -values to array
                     $preset->add_marks($announcement);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:101,代码来源:class.AnnouncementView.php

示例7: correct

 /**
  * correct handles the corrections of the protocol
  * 
  * @param int $pid entry-id for protocol
  * @return string html of the correction page
  */
 private function correct($pid)
 {
     // pagecaption
     $this->tpl->assign('pagecaption', parent::lang('class.ProtocolView#page#caption#correct'));
     // get protocol object
     $protocol = new Protocol($pid);
     $correctable = $protocol->get_correctable(false);
     // js tiny_mce
     $tmce = array('element' => 'protocol-0', 'css' => 'templates/protocols/tmce_' . $protocol->get_preset()->get_path() . '.css', 'transitem' => parent::lang('class.ProtocolView#new_entry#tmce#item'), 'transdecision' => parent::lang('class.ProtocolView#new_entry#tmce#decision'));
     // smarty
     $this->tpl->assign('tmce', $tmce);
     // check rights
     if (Rights::check_rights($pid, 'protocol', true) && (in_array($_SESSION['user']->get_id(), $correctable['correctors']) || $_SESSION['user']->get_userinfo('name') == $protocol->get_owner())) {
         // check owner
         if ($_SESSION['user']->get_userinfo('name') == $protocol->get_owner()) {
             // smarty
             $sPCo = new JudoIntranetSmarty();
             // check action
             if ($this->get('action') == 'diff' && $this->get('uid') !== false) {
                 // diff correction of $uid
                 // get correction
                 $correction = new ProtocolCorrection($protocol, $this->get('uid'));
                 // clean protocols for diff
                 $diffBase = html_entity_decode(preg_replace('/<.*>/U', '', $protocol->get_protocol()));
                 $diffNew = html_entity_decode(preg_replace('/<.*>/U', '', $correction->get_protocol()));
                 // smarty
                 $sJsDL = new JudoIntranetSmarty();
                 // activate difflib js-files
                 $this->tpl->assign('jsdifflib', true);
                 // set values for difflib
                 $difflib = array('protDiffBase' => 'protDiffBase-0', 'protDiffNew' => 'protDiffNew-0', 'protDiffOut' => 'diffOut', 'protDiffBaseCaption' => parent::lang('class.ProtocolView#correct#diff#baseCaption'), 'protDiffNewCaption' => parent::lang('class.ProtocolView#correct#diff#newCaption'));
                 // add difflib values to js-template
                 $sJsDL->assign('dl', $difflib);
                 $this->add_jquery($sJsDL->fetch('smarty.js-jsdifflib.tpl'));
                 // add diffOut to template
                 $sPCo->assign('diffOut', 'diffOut');
                 // build form
                 $form = new HTML_QuickForm2('diffCorrection', 'post', array('name' => 'diffCorrection', 'action' => 'protocol.php?id=correct&pid=' . $pid . '&action=diff&uid=' . $this->get('uid')));
                 $datasource = array('protocol' => $protocol->get_protocol(), 'protDiffBase' => $diffBase, 'protDiffNew' => $diffNew);
                 // add datasource
                 $form->addDataSource(new HTML_QuickForm2_DataSource_Array($datasource));
                 // renderer
                 $renderer = HTML_QuickForm2_Renderer::factory('default');
                 $renderer->setOption('required_note', parent::lang('class.ProtocolView#entry#form#requiredNote'));
                 // elements
                 // protocol text
                 $protocolTA = $form->addElement('textarea', 'protocol');
                 $protocolTA->setLabel(parent::lang('class.ProtocolView#entry#form#protocol') . ':');
                 $protocolTA->addRule('regex', parent::lang('class.ProtocolView#entry#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('textarea.desc') . ']', $_SESSION['GC']->get_config('textarea.regexp'));
                 // checkbox to mark correction as finished
                 $finished = $form->addElement('checkbox', 'finished');
                 $finished->setLabel(parent::lang('class.ProtocolView#entry#form#finished') . ':');
                 // hidden textareas for texts to diff
                 $protocolBase = $form->addElement('textarea', 'protDiffBase');
                 $protocolNew = $form->addElement('textarea', 'protDiffNew');
                 // submit-button
                 $form->addElement('submit', 'submit', array('value' => parent::lang('class.ProtocolView#entry#form#submitButton')));
                 // add form to template
                 $sPCo->assign('c', true);
                 $sPCo->assign('form', $form->render($renderer));
                 // validate
                 if ($form->validate()) {
                     // get form data
                     $data = $form->getValue();
                     // check finished
                     if (!isset($data['finished'])) {
                         $data['finished'] = 0;
                     }
                     $correctionUpdate = array('finished' => $data['finished']);
                     $protocolUpdate = array('protocol' => $data['protocol']);
                     // update
                     $protocol->update($protocolUpdate);
                     $correction->update($correctionUpdate);
                     $protocol->writeDb('update');
                     $correction->writeDb('update');
                     // message
                     $message = array('message' => parent::lang('class.ProtocolView#correct#message#corrected'), 'href' => 'protocol.php?id=correct&pid=' . $pid . '&action=diff&uid=' . $this->get('uid'), 'title' => parent::lang('class.ProtocolView#correct#message#back'), 'text' => parent::lang('class.ProtocolView#correct#message#back'));
                     // assign to template
                     $sPCo->assign('c', false);
                     $sPCo->assign('message', $message);
                 }
             } else {
                 // list all corrections
                 // get corrections
                 $corrections = ProtocolCorrection::listCorrections($pid);
                 // put information together
                 $list = array();
                 $user = new User();
                 foreach ($corrections as $correction) {
                     // change user
                     $user->change_user($correction['uid'], false, 'id');
                     // fill list
                     $img = false;
                     if ($correction['finished'] == 1) {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:101,代码来源:class.ProtocolView.php

示例8: testContainerValidation

 public function testContainerValidation()
 {
     $form = new HTML_QuickForm2('filters', 'post', null, false);
     $username = $form->addElement('text', 'foo');
     $username->addRule('required', 'Username is required');
     $form->addRecursiveFilter('trim');
     $this->assertFalse($form->validate());
     $this->assertSame('', $username->getValue());
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:9,代码来源:FilterTest.php

示例9: array

    return '<div class="form-actions">' . $submit . '</div>';
}
require_once 'HTML/QuickForm2/Renderer.php';
$renderer = HTML_QuickForm2_Renderer::factory('callback');
$renderer->setCallbackForId($submit->getId(), 'renderSubmit');
$renderer->setOption(array('errors_prefix' => 'El formulario contiene errores:', 'required_note' => '<span class="required">*</span> denota campos requeridos'));
////////////////////////////////////////////////////////////
include 'header.php';
echo '<div class="page-header">';
echo '  <h1>Listado de préstamos <small></small></h1>';
echo '</div>';
// Output javascript libraries, needed by hierselect
//echo $renderer->getJavascriptBuilder()->getLibraries(true, true);
$form->render($renderer);
echo $renderer;
if (!empty($_REQUEST['btnSubmit']) and $form->validate()) {
    //$q = strtr($_GET['q'], $normalizeChars);
    $sql_where = '';
    $sql_data = array();
    if (!empty($_GET['search'])) {
        $sql_where .= " and inventario || telefono || apellido_nombre || nro_documento || direccion ilike '%' || ? || '%' ";
        $sql_data[] = $_GET['search'];
    }
    if (!empty($_GET['sindevolucion'])) {
        $sql_where .= " and fecha_devolucion is null";
    }
    /*
     * mostramos los resultados
     */
    $sql .= $sql_where . ' order by fecha_prestamo';
    //echo $sql;
开发者ID:sergiokessler,项目名称:perio,代码行数:31,代码来源:prestamo_list.php

示例10: testFormRule

 public function testFormRule()
 {
     $form = new HTML_QuickForm2('track', 'post');
     $foo = $form->addElement('text', 'foo', array('id' => 'foo'));
     $form->addRule(new FormRule($form));
     $this->assertFalse($form->validate());
     $this->assertEquals('an error message', $foo->getError());
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:8,代码来源:QuickForm2Test.php

示例11: take

 /**
  * take creates the form to take an inventoryitem from somebody else
  * 
  * @param int $did entry-id for the inventoryitem
  * @return string html-string with the form
  */
 private function take($did)
 {
     // check rights
     if (Rights::check_rights($did, 'inventory')) {
         // pagecaption
         $this->tpl->assign('pagecaption', parent::lang('class.InventoryView#page#caption#take'));
         // get db-object
         $db = Db::newDb();
         // get inventory-object
         $inventory = new Inventory($did);
         // check owned
         if ($inventory->get_owned() == 'given') {
             // smarty-template
             $sT = new JudoIntranetSmarty();
             // prepare return
             $return = '';
             // get preset
             $preset = $inventory->get_preset();
             // get fields
             $fields = $preset->get_fields();
             // add headline
             $sT->assign('caption', parent::lang('class.InventoryView#take#page#headline') . ': ' . $inventory->get_name() . ' (' . $inventory->get_inventory_no() . ')');
             // add take from
             $movements = Inventory::movement_last_row($db, $inventory->get_id(), 'user_id', 2);
             $user = new User();
             $user->change_user($movements[1], false, 'id');
             $sT->assign('takefrom', parent::lang('class.InventoryView#take#page#TakeFrom') . ': ' . $user->get_userinfo('name'));
             // add accessory info
             $sT->assign('accessoryinfo', parent::lang('class.InventoryView#take#page#accessory.required'));
             // formular
             $form = new HTML_QuickForm2('inventory_take', 'post', array('name' => 'inventory_take', 'action' => 'inventory.php?id=take&did=' . $this->get('did')));
             // renderer
             $renderer = HTML_QuickForm2_Renderer::factory('default');
             $renderer->setOption('required_note', parent::lang('class.InventoryView#entry#form#requiredNote'));
             // generate field-quickform and add to form
             foreach ($fields as $field) {
                 // check if given
                 if ($inventory->movement_last_accessories($field) === true || $field->get_type() == 'text') {
                     // generate quickform
                     $field->read_quickform();
                 } else {
                     // generate quickform
                     $field->read_quickform(array('disabled' => 'disabled'));
                 }
                 // add to form
                 $form->appendChild($field->get_quickform());
             }
             // submit-button
             $form->addSubmit('submit', array('value' => parent::lang('class.InventoryView#take#form#submitButton')));
             // validate
             if ($form->validate()) {
                 // values
                 $values = $form->getValue();
                 // write to db
                 $insert_id = $this->movement_to_db('taken', $inventory->get_id(), $_SESSION['user']->userid());
                 // accessory to db
                 $this->values_to_db($insert_id, $fields, $values);
                 // headline
                 $sT->assign('action', $inventory->get_name() . ' (' . $inventory->get_inventory_no() . ') ' . parent::lang('class.InventoryView#take#page#headline.taken'));
                 // accessory
                 $sT->assign('accessoryaction', parent::lang('class.InventoryView#take#page#accessory.taken'));
                 // walk through fields
                 $data = array();
                 foreach ($fields as $field) {
                     // check value
                     if (isset($values['inventory-' . $field->get_id()])) {
                         $field_value = $values['inventory-' . $field->get_id()];
                     } else {
                         $field_value = 0;
                     }
                     // return field and value as HTML
                     $field->value($field_value);
                     $data[] = $field->value_to_html();
                 }
                 $sT->assign('form', '');
                 $sT->assign('data', $data);
             } else {
                 $sT->assign('form', $form->render($renderer));
             }
             // return
             return $sT->fetch('smarty.inventory.takegive.tpl');
         } else {
             // error
             $errno = $GLOBALS['Error']->error_raised('NotGivenTo', $this->get('id'), $did);
             $GLOBALS['Error']->handle_error($errno);
             return $GLOBALS['Error']->to_html($errno);
         }
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', $this->get('id'), $did);
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:100,代码来源:class.InventoryView.php

示例12: array

    //$form->addElement('static', null)
    //       ->setContent('<div class="col-xs-8 titus">')
    //;
    $form->addText("new_lista[{$lista_id}][votos_centro]", $votos_attr_centro);
    $form->addText("new_lista[{$lista_id}][votos_claustro]", $votos_attr_claustro);
    //$form->addElement('static', null)
    //       ->setContent('</div>')
    //;
}
$form->addElement('button', 'btnSubmit', array('type' => 'submit', 'value' => 'Guardar', 'class' => 'btn btn-lg btn-primary'))->setContent('Guardar');
require_once 'HTML/QuickForm2/Renderer.php';
require_once 'HTML/QuickForm2/JavascriptBuilder.php';
$renderer = HTML_QuickForm2_Renderer::factory('default');
//$renderer->setJavascriptBuilder(new HTML_QuickForm2_JavascriptBuilder(null, __DIR__ . '/../lib/pear/data/HTML_QuickForm2/js'));
$renderer->setOption(array('errors_prefix' => 'El formulario contiene errores:', 'required_note' => '<div><span class="required">*</span> denota campos requeridos</div>'));
if (isset($_REQUEST['btnSubmit']) and $_REQUEST['btnSubmit'] == 'Guardar' and $form->validate()) {
    $new_urna = $_REQUEST['new_urna'];
    $new_lista = $_REQUEST['new_lista'];
    $db->beginTransaction();
    $inserted = 0;
    foreach ($new_lista as $lista_id => $votos) {
        unset($new_row);
        $new_row['urna_id'] = $new_urna;
        $new_row['lista_id'] = $lista_id;
        if (isset($votos['votos_centro'])) {
            $new_row['votos_centro'] = $votos['votos_centro'];
        } else {
            $new_row['votos_centro'] = 0;
        }
        $new_row['votos_claustro'] = $votos['votos_claustro'];
        /****************************************************************
开发者ID:sergiokessler,项目名称:perio,代码行数:31,代码来源:carga.php

示例13: new_row


//.........这里部分代码省略.........
         // check id
         if ($col->name != 'id') {
             // col->type
             // 252 = text, 253 = varchar; 1 = tinyint(boolean); 3 = int
             // add field
             $field = null;
             // check category
             if ($col->name == 'category') {
                 // get options
                 $cat_sql = "SELECT id,name FROM category WHERE valid=1";
                 $cat_result = $db->query($cat_sql);
                 $options = array('--');
                 while (list($id, $name) = $cat_result->fetch_array(MYSQL_NUM)) {
                     $options[$id] = $name;
                 }
                 // select
                 $field = $form->addElement('select', $col->name, array());
                 $field->setLabel($translated_col . ':');
                 // load options
                 $field->loadOptions($options);
                 // add rules
                 if ($table == 'defaults') {
                     $field->addRule('required', parent::lang('class.AdministrationView#new_row#rule#requiredSelect'));
                     $field->addRule('callback', parent::lang('class.AdministrationView#new_row#rule#checkSelect'), array($this, 'callback_check_select'));
                 }
             } else {
                 // check type
                 if ($col->type == 252) {
                     // textarea
                     $field = $form->addElement('textarea', $col->name, array());
                     $field->setLabel($translated_col . ':');
                     // add rules
                     $field->addRule('regex', parent::lang('class.AdministrationView#new_row#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('textarea.desc') . ']', $_SESSION['GC']->get_config('textarea.regexp'));
                     // required
                     if ($table == 'defaults') {
                         $field->addRule('required', parent::lang('class.AdministrationView#new_row#rule#required'));
                     }
                 } elseif ($col->type == 253 || $col->type == 3) {
                     // input
                     $field = $form->addElement('text', $col->name, array());
                     $field->setLabel($translated_col . ':');
                     // add rules
                     $field->addRule('regex', parent::lang('class.AdministrationView#new_row#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('textarea.desc') . ']', $_SESSION['GC']->get_config('textarea.regexp'));
                     // required
                     if ($table == 'defaults') {
                         $field->addRule('required', parent::lang('class.AdministrationView#new_row#rule#required'));
                     }
                 } elseif ($col->type == 1) {
                     // input
                     $field = $form->addElement('checkbox', $col->name, array());
                     $field->setLabel($translated_col . ':');
                 }
             }
         }
         // increment field-counter
         $i++;
     }
     // submit-button
     $form->addSubmit('submit', array('value' => parent::lang('class.AdministrationView#new_row#form#submitButton')));
     // validate
     if ($form->validate()) {
         // set output
         $return .= $this->p('class="edit_caption"', parent::lang('class.AdministrationView#new_row#caption#done'));
         // get data
         $data = $form->getValue();
         // prepare statement
         $sql = "INSERT INTO {$table} ";
         $sql_field = "(id,";
         $sql_value = " VALUES (NULL,";
         foreach ($data as $field => $value) {
             // check translation
             $translated_field = '';
             if (parent::lang('class.AdministrationView#tableRows#name#' . $field) != "class.AdministrationView#tableRows#name#{$field} not translated") {
                 $translated_field = parent::lang('class.AdministrationView#tableRows#name#' . $field);
             } else {
                 $translated_field = $field;
             }
             // check field
             if (substr($field, 0, 5) != '_qf__' && $field != 'submit') {
                 // add fields to sql
                 $sql_field .= "{$field},";
                 $sql_value .= "'{$value}',";
                 // add fields to output
                 $return .= $this->p('', "{$translated_field} = '" . nl2br(htmlentities(utf8_decode($value))) . "'");
             }
         }
         $sql_field = substr($sql_field, 0, -1) . ")";
         $sql_value = substr($sql_value, 0, -1) . ")";
         $sql .= $sql_field . $sql_value;
         // execute
         $result = $db->query($sql);
         // add table content
         $return .= $this->list_table_content($table, $this->get('page'));
     } else {
         $return .= $this->p('', parent::lang('class.AdministrationView#new_row#caption#edit'));
         $return .= $form->render($renderer);
     }
     // return
     return $return;
 }
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:101,代码来源:class.AdministrationView.php

示例14: testObjectMessageProvider

 public function testObjectMessageProvider()
 {
     $mockProvider = $this->getMock('HTML_QuickForm2_MessageProvider', array('get'));
     $mockProvider->expects($this->once())->method('get')->will($this->returnValue('A nasty error happened!'));
     $form = new HTML_QuickForm2('upload', 'post', null, false);
     $upload = $form->addFile('local', array(), array('messageProvider' => $mockProvider));
     $this->assertFalse($form->validate());
     $this->assertEquals('A nasty error happened!', $upload->getError());
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:9,代码来源:InputFileTest.php

示例15: testServerSideValidationErrors

 public function testServerSideValidationErrors()
 {
     $ds = new HTML_QuickForm2_DataSource_Session(array('foo' => array('', 'blah', '')));
     $form = new HTML_QuickForm2('repeatValidate');
     $form->addDataSource($ds);
     $fieldset = new HTML_QuickForm2_Container_Fieldset();
     $text = new HTML_QuickForm2_Element_InputText('foo');
     $repeat = new HTML_QuickForm2_Container_Repeat(null, null, array('prototype' => $fieldset));
     $fieldset->appendChild($text);
     $form->appendChild($repeat);
     $text->addRule('required', 'a message');
     $this->assertFalse($form->validate());
     $ary = $repeat->render(HTML_QuickForm2_Renderer::factory('array'))->toArray();
     $this->assertEquals('a message', $ary['elements'][1]['elements'][0]['error']);
     $this->assertArrayNotHasKey('error', $ary['elements'][2]['elements'][0]);
     $this->assertEquals('a message', $ary['elements'][3]['elements'][0]['error']);
     $text->setId('blah-:idx:');
     $ary = $repeat->render(HTML_QuickForm2_Renderer::factory('array'))->toArray();
     $this->assertEquals('a message', $ary['elements'][1]['elements'][0]['error']);
     $this->assertArrayNotHasKey('error', $ary['elements'][2]['elements'][0]);
     $this->assertEquals('a message', $ary['elements'][3]['elements'][0]['error']);
 }
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:22,代码来源:RepeatTest.php


注:本文中的HTML_QuickForm2::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。