Of course, instead of using static variables, you can create getters to
retrieve values from configurations, so it will be easier to change the
number of allowed uploadable photos by simply changing a value in a
config/app.yml.
Something like
public function getMaxUploadablePhotos(){
return sfConfig::get('app_max_uploadable_photos');
}Cheers, Before Printing, Think about Your Environmental Responsibility! Avant d'Imprimer, Pensez à Votre Responsabilitée Environnementale! On Tue, Nov 23, 2010 at 1:39 PM, Raphael Schumacher < [email protected]> wrote: > To limit the number of uploadable photos to 6 at most: > > > // lib/form/doctrine/ProductForm.class.php > public function configure() > { > static $maxUploadablePhotos = 6; > static $maxUploadablePhotosAtOnce = 2; > > $form = new ProductPhotoCollectionForm(null, array( > 'product' => $this->getObject(), > 'size' => min($maxUploadablePhotosAtOnce, max(0, > $maxUploadablePhotos - count($this->getObject()->getPhotos()))), > )); > > $this->embedForm('newPhotos', $form); > } > > This solution may allow more than two photos to be uploaded at once, > but I guess you can adapt this easily to your desired behaviour. > > ---- > > If you don't want the user to edit the already uploaded photos, you > can simply use the unset($this['Photos']) call. most typically in the > configure() method of the form. An alternative (but with equal > effect): unset($this->widgetSchema['Photos'], $this- > >validatorSchema['Photos']); > > -RAPHAEL > > -- > 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]<symfony-users%[email protected]> > For more options, visit this group at > http://groups.google.com/group/symfony-users?hl=en > -- 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
