本文整理汇总了PHP中sfForm::getValidatorSchema方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::getValidatorSchema方法的具体用法?PHP sfForm::getValidatorSchema怎么用?PHP sfForm::getValidatorSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfForm
的用法示例。
在下文中一共展示了sfForm::getValidatorSchema方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: embedWidgetIntoForm
/**
* Embeds this widget into the form. Sets label and validator for this widget.
* @param sfForm $form
*/
public function embedWidgetIntoForm(sfForm &$form)
{
$widgetSchema = $form->getWidgetSchema();
$validatorSchema = $form->getValidatorSchema();
$widgetSchema[$this->attributes['id']] = $this;
$widgetSchema[$this->attributes['id']]->setLabel(__(ucwords(str_replace("_", " ", $this->attributes['id']))));
$validatorSchema[$this->attributes['id']] = new ohrmValidatorDateRange(array(), array("invalid" => "Insert a correct date"));
}
示例2: embedWidgetIntoForm
/**
* Embeds this widget into the form. Sets label and validator for this widget.
* @param sfForm $form
*/
public function embedWidgetIntoForm(sfForm &$form)
{
$widgetSchema = $form->getWidgetSchema();
$validatorSchema = $form->getValidatorSchema();
$widgetSchema[$this->attributes['id']] = $this;
$widgetSchema[$this->attributes['id']]->setLabel(ucwords(str_replace("_", " ", $this->attributes['id'])));
$required = $requiredMessage = __(ValidationMessages::REQUIRED);
$validatorSchema[$this->attributes['id']] = new ohrmValidatorConditionalFilter(array(), array('required' => $requiredMessage));
}
示例3: embedWidgetIntoForm
public function embedWidgetIntoForm(sfForm $form)
{
$widgetSchema = $form->getWidgetSchema();
$validatorSchema = $form->getValidatorSchema();
$widgetSchema['from_date'] = new ohrmWidgetDatePicker(array(), array('id' => 'from_date'));
$widgetSchema['from_date']->setLabel("From ");
$form->setValidator('from_date', new sfValidatorDate());
$widgetSchema['to_date'] = new ohrmWidgetDatePicker(array(), array('id' => 'to_date'));
$widgetSchema['to_date']->setLabel("To ");
$form->setValidator('to_date', new sfValidatorDate());
$validatorSchema->setPostValidator(new sfValidatorSchemaCompare('from_date', sfValidatorSchemaCompare::LESS_THAN_EQUAL, 'to_date', array('throw_global_error' => true), array('invalid' => 'The from date ("%left_field%") must be before the to date ("%right_field%")')));
return $form;
}
示例4: processValidationRules
public function processValidationRules($name, sfForm $form, $is_embedded = false)
{
foreach ($form->getValidatorSchema()->getFields() as $fieldname => $objField) {
// ignore the csrf field
if ($fieldname == '_csrf_token') {
continue;
}
// get the correct html "name" for this field
$validation_name = $this->createValidationName($name, $fieldname, $is_embedded);
$this->processRules($validation_name, $objField, $form, $fieldname);
$this->processMessages($validation_name, $objField);
}
}
示例5: embedWidgetIntoForm
/**
* Embeds this widget into the form. Sets label and validator for this widget.
* @param sfForm $form
*/
public function embedWidgetIntoForm(sfForm &$form)
{
$widgetSchema = $form->getWidgetSchema();
$validatorSchema = $form->getValidatorSchema();
$widgetSchema[$this->attributes['id']] = $this;
$widgetSchema[$this->attributes['id']]->setLabel(ucwords(str_replace("_", " ", $this->attributes['id'])));
$requiredMessage = __(ValidationMessages::REQUIRED);
$validatorSchema[$this->attributes['id']] = new ohrmValidatorConditionalFilter(array(), array('required' => $requiredMessage));
//$form->setValidator('date_period', new sfValidatorString());
// $validatorSchema[$this->attributes['id']] = new ohrmValidatorDateRange(array(), array("invalid" => "Insert a correct date"));
// $validatorSchema[$this->attributes['id']] = new sfValidatorPass();
// $validatorSchema->setPostValidator(new ohrmValidatorSchemaDateRange($this->attributes['id'], ohrmValidatorSchemaDateRange::LESS_THAN_EQUAL, $this->attributes['id'],
// array('throw_global_error' => true),
// array('invalid' => 'The from date ("%left_field%") must be before the to date ("%right_field%")')
// ));
}
示例6: correctValidators
/**
* Replacing validators with their up-to-date equivalent from an embedded form.
*
* @param sfForm $form Form instance on which to replace validators
*
* @return sfValidatorSchema
*/
protected function correctValidators($form)
{
foreach ($form->getEmbeddedForms() as $field => $embed) {
if ($form->getValidator($field) instanceof sfValidatorSchema) {
foreach ($embed->getValidatorSchema()->getFields() as $name => $validator) {
if (!$form->getValidator($field)->offsetExists($name)) {
$embed->getValidatorSchema()->offsetUnset($name);
}
}
$form->setValidator($field, $this->correctValidators($embed));
}
}
return $form->getValidatorSchema();
}
开发者ID:AUTOPLANNING,项目名称:sfDoctrineDynamicFormRelationsPlugin,代码行数:21,代码来源:sfDoctrineDynamicFormRelations.class.php
示例7: changeContentSlotValueWidget
/**
* Change the content slot form value widget
*
* @param string $type The type of the widget
* @param sfForm $form The form whose slot will be modified
* @param string $fieldName The name of the "slot" field on the form
* @return void
*/
public static function changeContentSlotValueWidget(sfSympalContentSlot $slot, sfForm $form)
{
// in case the type is blank
$type = $slot->type ? $slot->type : 'Text';
$widgetSchema = $form->getWidgetSchema();
$validatorSchema = $form->getValidatorSchema();
$contentSlotTypes = sfSympalConfig::get('content_slot_types', null, array());
$options = isset($contentSlotTypes[$type]) ? $contentSlotTypes[$type] : array();
$widgetClass = isset($options['widget_class']) ? $options['widget_class'] : 'sfWidgetFormSympal' . $type;
$widgetOptions = isset($options['widget_options']) ? $options['widget_options'] : array();
$validatorClass = isset($options['validator_class']) ? $options['validator_class'] : 'sfValidatorFormSympal' . $type;
$validatorOptions = isset($options['validator_options']) ? $options['validator_options'] : array();
$validatorOptions['required'] = false;
/*
* Setup the widget and validator: 3 cases:
* 1) widget_class & is validator_class are not false, so we setup widget/validator using those
* 2) widget_class & validator_class ARE false, the slot is a column - get the widget/validator from the content form
* 3) All else fails, leave widget & validator alone
*/
if ($widgetClass && $validatorClass) {
$widgetSchema['value'] = new $widgetClass($widgetOptions, array('class' => 'slot_' . strtolower($type)));
$validatorSchema['value'] = new $validatorClass($validatorOptions);
} elseif ($slot->is_column) {
$contentForm = $slot->getContentSlotColumnForm();
$contentWidgetSchema = $contentForm->getWidgetSchema();
$contentValidatorSchema = $contentForm->getValidatorSchema();
$widgetSchema['value'] = $contentForm->getWidgetSchema()->offsetGet($slot->name);
$validatorSchema['value'] = $contentForm->getValidatorSchema()->offsetGet($slot->name);
}
}
示例8: changeContentSlotValueWidget
/**
* Change the content slot form value widget
*
* @param sfSympalContentSlot $contentSlot
* @param sfForm $form
* @return void
*/
public static function changeContentSlotValueWidget(sfSympalContentSlot $contentSlot, sfForm $form)
{
if ($contentSlot->is_column) {
return;
}
$type = $contentSlot->type ? $contentSlot->type : 'Text';
$widgetSchema = $form->getWidgetSchema();
$validatorSchema = $form->getValidatorSchema();
$contentSlotTypes = sfSympalConfig::get('content_slot_types', null, array());
$options = isset($contentSlotTypes[$type]) ? $contentSlotTypes[$type] : array();
$widgetClass = isset($options['widget_class']) ? $options['widget_class'] : 'sfWidgetFormSympal' . $type;
$widgetOptions = isset($options['widget_options']) ? $options['widget_options'] : array();
$validatorClass = isset($options['validator_class']) ? $options['validator_class'] : 'sfValidatorFormSympal' . $type;
$validatorOptions = isset($options['validator_options']) ? $options['validator_options'] : array();
$validatorOptions['required'] = false;
$widgetSchema['value'] = new $widgetClass($widgetOptions);
$validatorSchema['value'] = new $validatorClass($validatorOptions);
}
示例9: js_form_fields
function js_form_fields(sfForm $form)
{
$fieldSc = $form->getFormFieldSchema();
$loginFormItems = '';
$widget = $fieldSc->getWidget();
$validatorSchema = $form->getValidatorSchema();
foreach ($widget->getFields() as $key => $object) {
// echo($key);
$label = $fieldSc->offsetGet($key)->renderLabelName();
$type = $object->getOption('type');
if ($type == 'text') {
$type = 'textfield';
}
$name = $widget->generateName($key);
$allowBlank = 'true';
$extraItem = '';
if ($validatorSchema[$key] instanceof sfValidatorCSRFToken) {
$csrfToken = $form->getDefault($key);
$extraItem = ",value:'" . $csrfToken . "'";
}
if (isset($validatorSchema[$key]) and $validatorSchema[$key]->getOption('required') == true) {
$allowBlank = 'false';
}
$loginFormItems[] = "{id:'" . $key . "',fieldLabel: '" . $label . "',name: '" . $name . "',inputType:'" . $type . "',allowBlank:" . $allowBlank . $extraItem . "}\n\t\t";
}
// die();
$loginFormItems = implode(",", $loginFormItems);
// echo($loginFormItems);
// echo("<script>alert('oi');</script>");
return $loginFormItems;
}