Christian wrote, On 10/7/10 5:46 AM:
if (sfContext::getInstance()->getConfiguration()->getApplication() ==
'backend) {
$this->widgetSchema['payment_type_id'] = new
sfWidgetFormSelect(array('choices' => $choices));
} else {
$this->widgetSchema['payment_type_id'] = new
asWidgetFormSelectRadio(array('choices' => $choices));
}
hope this help u
On 7 Okt., 03:10, Andrei Dziahel <[email protected]> wrote:
Hi.
So why not to create 2 separate form classes which extend BaseVideoForm (or
VideoForm — depends of your needs and ), fill their configure()method with
application-specific code and use both in appropriate applications?
On Thu, Oct 7, 2010 at 01:55, Manu SW <[email protected]> wrote:
Hi,
Sorry if this is a n00b question ...
I would like to use the same form in both frontend and backend application
but I would need to change some widget types, depending on the application I
am using the form.
For example I have the form definition:
class VideoForm extends BaseVideoForm
{
public function configure()
{
parent::setup();//pkWidgetFormInputFilePersistent
//pkValidatorFilePersistent
$this->setWidgets(array(
'object_id' => new sfWidgetFormInputHidden(),
'user_id' => new sfWidgetFormInputHidden(),
'media_file' => new sfWidgetFormInputFile(array(
'label' => 'Mi Video',
//'file_src' =>
'/uploads/media/'.$this->getObject()->getMediaFile(),
//'is_image' => false,
//'edit_mode' => false,
//'template' => '<div>%input%</div>',
)),
'is_stream' => new sfWidgetFormInputHidden(),
'date_created' => new sfWidgetFormInputHidden()
));
....
I this definition is fine for the frontend definition but I would like to
change the 'object_id' and 'user_id' to be a sfWidgetFormChoice when I use
the form in the backend application.
Any idea or pointer someone could give me about the best way to achieve
that?
(that's an app I am maintaining in symfony 1.2.5)
Thanks !
M.
--
With the best regards, Andrei.
Thanks a lot Chirstian and Andrei for your reply !
I have taken Christian's approach and it works great.
I also tried Andrei's suggestion to create another instance of the form.
As i use the admin generator for that module it was fast to add a line
in backend/modules/bla/config/generator like :
form: ~
class: VideoBackendForm
It also worked.
But if i wasn't using admin generator for this module it would have been
a bit of a pain to initialize my backend form explicitly in every actions.
Cheers !
M.
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en