protected function appendMobileInputMode() { parent::appendMobileInputMode(); foreach ($this as $k => $v) { $widget = $this->widgetSchema[$k]; $validator = $this->validatorSchema[$k]; if ($widget instanceof opWidgetFormInputIncreased) { opToolkit::appendMobileInputModeAttributesForFormWidget($widget, 'numeric'); } } }
protected function appendMobileInputMode() { foreach ($this as $k => $v) { $widget = $this->widgetSchema[$k]; $validator = $this->validatorSchema[$k]; if (!$widget instanceof sfWidgetFormInput) { continue; } if ($widget instanceof sfWidgetFormInputPassword) { opToolkit::appendMobileInputModeAttributesForFormWidget($widget, 'alphabet'); } elseif ($validator instanceof sfValidatorEmail) { opToolkit::appendMobileInputModeAttributesForFormWidget($widget, 'alphabet'); } elseif ($validator instanceof sfValidatorNumber) { opToolkit::appendMobileInputModeAttributesForFormWidget($widget, 'numeric'); } } }
/** * @see sfWidgetFormDate */ public function render($name, $value = null, $attributes = array(), $errors = array()) { $dateTimeValue = is_array($value) ? sprintf('%04d-%02d-%02d', $value['year'], $value['month'], $value['day']) : $value; try { $dateTime = new DateTime($dateTimeValue); } catch (Exception $e) { $dateTime = new DateTime(); $dateTimeValue = null; } $dayDefault = $dateTime->format('j'); $monthDefault = $dateTime->format('n'); $year = $dateTime->format('Y'); $days = $this->getOption('days'); $months = $this->getOption('months'); if ($this->getOption('can_be_empty')) { $emptyValues = $this->getOption('empty_values'); $days = array('' => $emptyValues['day']) + $days; $months = array('' => $emptyValues['month']) + $months; if (!$dateTimeValue) { $dayDefault = $emptyValues['day']; $monthDefault = $emptyValues['month']; $year = $emptyValues['year']; } } if (is_array($value) && !checkdate((int) $value['month'], (int) $value['day'], (int) $value['year'])) { $dayDefault = $value['day']; $monthDefault = $value['month']; $year = $value['year']; } // days $widget = new sfWidgetFormSelect(array('choices' => $days), array_merge($this->attributes, $attributes)); $date['%day%'] = $widget->render($name . '[day]', $dayDefault); // months $widget = new sfWidgetFormSelect(array('choices' => $months), array_merge($this->attributes, $attributes)); $date['%month%'] = $widget->render($name . '[month]', $monthDefault); // years $attributes['size'] = '5'; $widget = new sfWidgetFormInput(array(), array_merge(array('class' => 'input_text'), $this->attributes, $attributes)); if ('mobile_frontend' === sfConfig::get('sf_app')) { opToolkit::appendMobileInputModeAttributesForFormWidget($widget, 'numeric'); } $date['%input_year%'] = $widget->render($name . '[year]', $year); return strtr($this->getOption('format'), $date); }
public function configure() { $this->setWidget('mail_address', new sfWidgetFormInputText()); $this->setValidator('mail_address', new sfValidatorPass()); if ($this->getOption('invited')) { $this->setWidget('message', new sfWidgetFormTextarea()); $this->setValidator('message', new sfValidatorPass()); $this->widgetSchema->setLabel('message', 'Message(Arbitrary)'); } $callback = new sfValidatorCallback(array('callback' => array($this, 'validate'))); $callback->setMessage('invalid', 'invalid e-mail address'); $this->validatorSchema->setPostValidator($callback); if (sfConfig::get('op_is_use_captcha', false)) { $this->embedForm('captcha', new opCaptchaForm()); } if ('mobile_frontend' === sfConfig::get('sf_app')) { opToolkit::appendMobileInputModeAttributesForFormWidget($this->getWidget('mail_address'), 'alphabet'); } }
$hasRequiredField = false; ?> <?php slot('form'); foreach ($forms as $form) { echo $form->renderHiddenFields(); foreach ($form as $name => $field) { if ($field->isHidden()) { continue; } $attributes = array(); $widget = $field->getWidget(); $validator = $form->getValidator($name); if ($widget instanceof sfWidgetFormInputPassword) { $widget = opToolkit::appendMobileInputModeAttributesForFormWidget($widget, 'alphabet'); } if ($widget instanceof opWidgetFormProfile) { $widget = $widget->getOption('widget'); $validator = $validator->getOption('validator'); } if ($widget instanceof sfWidgetFormChoice) { if ($widget->getRenderer() instanceof sfWidgetFormSelectRadio || $widget->getRenderer() instanceof sfWidgetFormSelectCheckbox) { $widget->setOption('renderer_options', array_merge(array('formatter' => array('opWidgetFormSelectFormatterMobile', 'formatter'), 'separator' => "<br>\n"), $widget->getOption('renderer_options'))); } } elseif ($widget instanceof sfWidgetFormSelectRadio || $widget instanceof sfWidgetFormSelectCheckbox) { $widget->setOption('formatter', array('opWidgetFormSelectFormatterMobile', 'formatter')); $widget->setOption('separator', "<br>\n"); } if ($options['mark_required_field'] && !$validator instanceof sfValidatorPass && !$validator instanceof sfValidatorSchema && $validator->getOption('required')) { echo sprintf('<font color="%s">*</font>', opColorConfig::get('core_color_22'));