本文整理汇总了PHP中sfForm::setWidget方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::setWidget方法的具体用法?PHP sfForm::setWidget怎么用?PHP sfForm::setWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfForm
的用法示例。
在下文中一共展示了sfForm::setWidget方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configureJCropWidgets
/**
* Takes a form and configures each image's widget.
*
* This is one of only 2 methods the user needs to call manually (the other being configureJCropValidators)
* Should be called from the form's configure() method
*
* @param sfForm $form
*/
public function configureJCropWidgets(sfForm $form, $formOptions = array())
{
foreach ($this->_options['images'] as $fieldName) {
if (!($imageConfig = $this->getImageConfig($fieldName))) {
continue;
}
$form->setWidget($fieldName, new sfWidgetFormInputFileInputImageJCroppable(array('invoker' => $this->getInvoker(), 'image_field' => $fieldName, 'image_ratio' => isset($imageConfig['ratio']) ? $imageConfig['ratio'] : false, 'with_delete' => true, 'file_src' => $this->getImageSrc($fieldName, 'editable'), 'template' => '%file%<br />%input%<br />%delete% %delete_label%', 'form' => $form)));
foreach (array('x1', 'y1', 'x2', 'y2') as $suffix) {
$form->setWidget($fieldName . '_' . $suffix, new sfWidgetFormInputHidden());
}
}
}
示例2: embedForm
/**
* Just to make sure every time a form is embedded, the 'remove' widgets
* are added. They are needed in the deleting process
*/
public function embedForm($name, sfForm $form, $decorator = null)
{
if ($form instanceof sfFormDoctrine) {
$form->setWidget('remove', new sfWidgetFormInputHidden(array(), array('class' => 'remove')));
$form->setValidator('remove', new sfValidatorPass());
}
parent::embedForm($name, $form, $decorator);
}
示例3: 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());
}
}
}
示例4: addImageField
/**
* Add a validated image upload field to a form.
*
* @param sfForm $form Form to modify
* @param string $field_name Name of the image upload field, default 'image'
*/
public static function addImageField($form, $field_name = 'image')
{
$form->setWidget($field_name, new sfWidgetFormInputFile());
$form->setValidator($field_name, new sfValidatorImageFile(self::getValidatorOptions(), self::getValidatorMessages()));
}
示例5: sfForm
</div>
<?php
}
?>
</div>
<?php
if ($name == 'polyline') {
?>
<!-- TODO The first two lines should be in action. -->
<div class="add-stop-wrapper">
<?php
$oneFieldForm = new sfForm();
?>
<?php
$oneFieldForm->setWidget('nj_stop_id', new sfWidgetFormDoctrineChoice(array('model' => 'NjStop', 'add_empty' => false)));
?>
<?php
$oneFieldForm->setWidget('nj_stop_lat_lng', new sfWidgetFormDoctrineChoice(array('model' => 'NjStop', 'method' => 'getLatitudeLongitude', 'add_empty' => false)));
?>
<?php
echo $oneFieldForm['nj_stop_id']->render();
?>
<div class="nj_stop_lat_lng_wrapper" style="display:none;">
<?php
echo $oneFieldForm['nj_stop_lat_lng']->render();
?>
</div>
<a href="#add-stop" title="Add Stop" class="btn-add-stop">Add Stop</a>
</div>
<div class="map_wrapper">
示例6: changeThemeWidget
/**
* Change theme widget to be dropdown of themes
*
* @param sfForm $form
* @return void
*/
public static function changeThemeWidget(sfForm $form)
{
$array = self::getThemeWidgetAndValidator();
$form->setWidget('theme', $array['widget']);
$form->setValidator('theme', $array['validator']);
}