こんにちは、三寒四温を感じ、春が待ち通しい塩浦です。 弊社では今まで、symfony1系の利用が多かったのですが、現在は、Symfony2系での開発に移行がすすんでいます。 同じ名前のPHPのフレームワークですが、symfony1系のときとは、かなり勝手が違っているのをいろいろな場面で感じます。 そんな開発の中で、私がハマってしまったモノを紹介させていただいて、Symfony2系で同じように悩んでいる方の少しでもお助けになれば共います。 さっそくですが、実践的な内容として、動的フォームなどを実現する場合、symfony1系でもそうでしたが、embedにてフォームを実現することが多いかと思います。 embedフォームの実現方法は、公式のこちらのページに記載されています。>>http://symfony.com/doc/2.1/cookbook/form/form_collections.ht
Services Platform.sh for Symfony Best platform to deploy Symfony apps SymfonyInsight Automatic quality checks for your apps Symfony Certification Prove your knowledge and boost your career SensioLabs Professional services to help you with Symfony Blackfire Profile and monitor performance of your apps
前のエントリの続き。 カスタムFormTypeのコンストラクタ引数にDoctrine\ORM\EntityManagerオブジェクトを渡せばOK。 以下、都道府県を選択するカスタムFormTypeを作る場合の例。 手順1:Symfony\Component\Form\AbstractTypeのサブクラスを作成する 引数がDoctrine\Common\Persistence\ObjectManagerインターフェースとなっているが、EntityManagerクラスはObjectManagerインターフェースを実装している。 MPrefは都道府県一覧を格納したテーブル(m_pref)に対するEntityクラス。 <?php namespace Acme\FormTypeBundle\Form\Type; use Symfony\Component\Form\AbstractType; use
アプリケーションを開発していくうえでカスタムバリデーションを作るまでもないけど、 独自のバリデーションを追加したかったり、動的にバリデーションを行いたいことがよくある。 Symfony2ではどのように行うのかメモっておく。 例えばお問い合わせフォームなどで、利用規約の同意にチェックが入っていないと送信できないようにしたい。 この例の場合、フォームクラスは下記のようになる。 <?php namespace Sample\Bundle\DemoBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\CallbackValidator; use Symfony\Component\Form\FormIn
Services Platform.sh for Symfony Best platform to deploy Symfony apps SymfonyInsight Automatic quality checks for your apps Symfony Certification Prove your knowledge and boost your career SensioLabs Professional services to help you with Symfony Blackfire Profile and monitor performance of your apps What about Silex in a Symfony 4 world? During the last few months, and as an exercise when working
Symfony is a set of reusable PHP components... The standard foundation on which the best PHP applications are built. Choose any of the 50 stand-alone components available for your own applications. Browse components ... and a PHP framework for web projects Speed up the creation and maintenance of your PHP web applications. End repetitive coding tasks and enjoy the power of controlling your code. W
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く