开发者

Extend Symfony2 White October Admin Bundle Form Fields?

This question is quite specific. I'm using Symfony2 White October Admin Bundle for generating administration for my application. I wonder if anyone has experience with this bundle and knows how to modify specific fields added to Admin class. The bundle is not documented very well and I'd like to know, if there are methods for doing this, or does the bundle core need to be extended.

For example I've got a Speaker entity with a field storing the path to one's avatar:

/**
 * @var string $picturePath
 *
 * @ORM\Column(name="picture_path", type="string", length=128, nullable=false)
 */
private $picturePath;

Then 开发者_如何学Cin the Admin class I'm adding the field:

protected function configure()
{
    ...
    ...
    ->addFields(array(
        ...
        ...
        'picturePath'=> array("label" => "Avatar"),
    ));
}

Is there an easy way to tell the bundle that I'd like this field to be an upload field instead of a text field, and define extra methods to call after submitting the form? (e.g. resize the image, store it, and then just store the image path in the DB)


As I haven't found any solution yet, I had to rape my entities to do that. So I modified the basic setter methods to call other methods inside the entity that do the dirty job. This is not a solution, and I'll still be happy if I could find better answers here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜