Category Archives: forms

symfony 1.4 embedForm 保存2次问题

When a form is embedded, the embedded model representation is saved twice: one via fromArray(), that automatically hydrates related components, and another time via saveEmbeddedForm. 使用embed会出现insert 2次的问题 configure(){ embedRelation(‘ForwardProfile’); } function addProfile(){ //embed a new form $profiles = new sfForm(); … Continue reading

Posted in forms | Comments Off

symfony 关联id必须unset才会自动添加

数据库结构2个表: user ———- id name ———- book ———- id user_id(fk) name ———- bookForm.class.php的configure()设置 unset($this['user_id']); 这样embedForm后,user_id值自动添加为user的id值

Posted in forms | Comments Off

添加多条记录,字段为空则不添加(bind)

目的: 用户自定义数目的记录,有内容的input则插入数据库,没内容则忽略 例子: 已经embed的字段要用unset()才不会插入数据库 /lib/…/xxForm.class.php … public function addNewTargets($number) { $targets = new sfForm(); for($i=0;$i<$number;$i++) { $target = new WeightTarget(); $target->setWeightWatcher($this->getObject()); $target_from = new WeightTargetForm($target); $targets->embedForm($i, $target_from); } $this->embedForm(‘new’, $targets); } public function bind(array $taintedValues = null, array $taintedFiles = … Continue reading

Posted in Uncategorized, forms | Comments Off

Embedded forms with symfony 1.4 and jQuery

http://tech.cibul.org/embedded-forms-with-symfony-1-4-and-jquery/ How to implement a single interface to insert multiple entries linked by one-to-many relations… I’ve been looking recently for a way to build a form that would allow the input of data (edition or adding new data) into multiple … Continue reading

Posted in Uncategorized, forms | Comments Off

symfony上传文件

symfony 1.2 利用form类,设置文件上传。 class WorldImagesForm extends BaseWorldImagesForm { public function configure() { $this->widgetSchema['file'] = new sfWidgetFormInputFile(); $this->validatorSchema['file'] = new sfValidatorFile(array( ‘required’ => false, ‘path’ => sfConfig::get(‘sf_upload_dir’).’/images/guide’, ‘max_size’ => ’5242880′, ‘mime_types’ => ‘web_images’), array( ‘max_size’ => ‘最大15Mb!’, ‘mime_types’ => ‘只支持web图片格式’ )); … Continue reading

Posted in forms | Comments Off

定义select下拉框的empty默认值

使用下拉列表时,常会遇到再下拉框第一项设置”请选择…”等字样

Posted in forms | Comments Off

使用sfFormExtraPlugin添加Tiny mce文本编辑器

步骤很简单,但第一次搞总是会遇到这样那样的问题,这里给出安装过程.

Posted in forms | Comments Off

symfony forms 中文教程:第一章创建表单(2)

显示表单

Posted in forms | Comments Off

symfony forms 中文教程:第一章创建表单(1)

Posted in forms | Comments Off

sfValidatorSchemaCompare错误

sfValidatorSchemaCompare()用来比较两个field值。

Posted in forms | Comments Off

bind()与validator表单验证

今天遇到问题,明明setOptions(‘required’,true)但提交空表单renderError却不显示错误。

Posted in forms | Comments Off

Symfony Forms: Change validators at runtime

Let’s say you have to make a user form with password fields.

Posted in forms | Comments Off