dongzhan5246 2014-05-12 13:21
浏览 8
已采纳

Symfony2 + Doctrine + FormType,关系和动态添加行

first look: enter image description here

i have made this DB structure with entities than dumped and visualised.

Adding things to DB from phpMyAdmin or displaying data from code is no problem, but when i try to build form using formtype like:

  1. main form is CV (curriculum vitae)
  2. this contains one text field
  3. relation to skills of user (skill, degree) (now i can only select existing skill of the user, added through phpmyadmin)
  4. same as skills for employments, schools,..

my mind want to blow from weirdness. Can someone help me?

I want to build form where i can fill anything on one page. Eg.:

  1. user writes something about himself

  2. for example he clicks on add new school, and form for schools will appear, if he have more schools, he can add another (without reloading page and saving actual form)

  3. same with employments, click add new,...

  4. at skills he can select the skill he knows (for example C++ Programing), click add and than can select or enter the degree (0 Begginer, 1...3 Expert). Adding more needs to be possible as with 3. and 2.

  5. as final step he clicks on the "Save CV"

And anything done.

I have tried:

         ->add('skills', 'collection', array(
                'type' => new SkillsType(),
                'label' => 'Skills',
                'error_bubbling' => true,
                'cascade_validation' => true,
                    ))

With Template:

{{ form_start(form) }}
{% for skill in form.skills %}
    <li>
        {{ form_widget(skill) }}
    </li>
{% endfor %}
{{ form_end(form) }}

to add skills then i wanted to use the same for adding employments.

At wort i will make manual form with couple of javascript.

Thankyou

  • 写回答

1条回答 默认 最新

  • dtn913117 2014-05-12 14:13
    关注

    The Collection field type is what your using. If you havent already its work looking at the Documentation for it.

    You can do what you want by using the prototype property which Symfony will add to your form if you add the allow_add option in your form builder.

    Collection Field Type

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 Keil uVision5创建project没反应
  • ¥15 mmseqs内存报错
  • ¥15 vika文档如何与obsidian同步
  • ¥15 华为手机相册里面的照片能够替换成自己想要的照片吗?
  • ¥15 陆空双模式无人机飞控设置
  • ¥15 sentaurus lithography
  • ¥100 求抖音ck号 或者提ck教程
  • ¥15 关于#linux#的问题:子进程1等待子进程A、B退出后退出(语言-c语言)
  • ¥20 web页面如何打开Outlook 365的全球离线通讯簿功能
  • ¥15 io.jsonwebtoken.security.Keys