で追加のフィールドを定義する場合generator.yml
は、アドミン ジェネレーター アクションの 1 つをオーバーライドして、必要に応じてフィールドを処理できます。
cache/YOURAPP/YOURENV/modules/autoYOURMODULE/actions/actions.class.phpで生成されたactions.class.php を見てください。apps/YOURAPP/modules/YOURMODULE/actions/actions.class.phpで、これらの関数を独自の関数でオーバーライドできます。これは、キャッシュされたファイルから継承されるためです。generator.confに変更を加えると、キャッシュされたファイルが更新されますが、コードは引き続きそれをオーバーライドします。おそらくオーバーライドしたいでしょう。 processForm()
このブログ投稿のステップ 5 に、この例があります。
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid())
{
$notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
// NEW: deal with tags
if ($form->getValue('remove_tags')) {
foreach (preg_split('/\s*,\s*/', $form->getValue('remove_tags')) as $tag) {
$form->getObject()->removeTag($tag);
}
}
if ($form->getValue('new_tags')) {
foreach (preg_split('/\s*,\s*/', $form->getValue('new_tags')) as $tag) {
// sorry, it would be better to not hard-code this string
if ($tag == 'Add tags with commas') continue;
$form->getObject()->addTag($tag);
}
}
try {
$complaint = $form->save();
// and the remainder is just pasted from the generated actions file
キャッシュ内の生成されたファイルを読み取って、admin ジェネレーターが何を行っているかを正確に確認できること、およびそれらの任意の部分をオーバーライドできることに気付いたとき、admin ジェネレーターの生産性が大幅に向上しました。