本文整理汇总了PHP中sfForm::getWidget方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::getWidget方法的具体用法?PHP sfForm::getWidget怎么用?PHP sfForm::getWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfForm
的用法示例。
在下文中一共展示了sfForm::getWidget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replaceWidgets
public static function replaceWidgets(sfForm $form)
{
foreach ($form->getWidgetSchema()->getFields() as $name => $widget) {
if ($widget instanceof sfWidgetFormDate) {
$form->setWidget($name, self::getDateWidget());
} elseif ($widget instanceof sfWidgetFormFilterDate) {
$form->getWidget($name)->setOption("from_date", self::getDateWidget(array("use_own_help" => false)));
$form->getWidget($name)->setOption("to_date", self::getDateWidget(array("use_own_help" => false)));
$form->getWidget($name)->setOption("template", __("from %from_date% to %to_date%"));
} elseif ($widget instanceof sfWidgetFormTextarea) {
$form->getWidget($name)->setAttribute("rows", 15);
$form->getWidget($name)->setAttribute("cols", 100);
}
if ($name == "attachment") {
$form->setWidget($name, new sfWidgetFormInputFile());
} elseif ($name == "created_by" || $name == "updated_by") {
if ($form instanceof sfFormPropel) {
$form->setWidget($name, new sfWidgetFormInputHidden());
}
} elseif ($name == "password") {
$form->setWidget($name, new sfWidgetFormInputPassword());
}
}
}
示例2: getFormFieldContainerClass
public function getFormFieldContainerClass(sfForm $form, $name)
{
$class = array('form-element');
$attributes = array();
if (isset($form[$name]))
{
$widget = $form->getWidget($name);
$validator = $form->getValidator($name);
switch (true)
{
case $validator->getOption('required') === true:
$class[] = 'required';
break;
default:
$class[] = sfInflector::underscore(str_replace('sfWidgetForm', '', get_class($widget)));
break;
}
}
return implode(' ', $class);
}
示例3: getLabel
protected static function getLabel(sfForm $form, $name)
{
try {
$widget = $form->getWidget($name);
} catch (Exception $e) {
$widget = null;
}
if ($widget) {
$label = $widget->getLabel();
if ($label) {
return $label;
}
$placeholder = $widget->getAttribute('placeholder');
if ($placeholder) {
return $placeholder;
}
}
return $name;
}