I've followed some answers on here and from what I can find on Google but I'm unable to override the renderOptions and setLabelPosition function in the FormMultiCheckbox helper.
I've created a new FormMultiCheckbox.php and saved it in my Application/Form/View/Helper folder and in this file I've redefined the renderOptions and setLabelPostion functions.
Then in Modue.php I've added the following line to the getViewHelperConfig function:
'invokables' => array(
'formmulticheckbox' => 'Application\Form\View\Helper\FormMultiCheckbox'
),
And in my view I'm adding the input to the screen with the following line:
echo $this->formRadio($about_you_form->get('user_gender'), 'block')
Where block is the new layout for the element I've created.
I'm basically trying to get the element to output the input first and then the label instead of putting everything inside the label tags.
I've tried both answers on this post (How to use a custom form view helper in Zend Framework 2?) but I'm getting the error message:
Zend\Form\View\Helper\FormMultiCheckbox::setLabelPosition expects either Zend\Form\View\Helper\FormMultiCheckbox::LABEL_APPEND or Zend\Form\View\Helper\FormMultiCheckbox::LABEL_PREPEND; received "block"
Which would suggest to me that it is not picking up my new renderOptions or setLabelPosition as the error message has been changed in the latter.
Any help or pointers much appreciated.
Regards,
Sean
Zend\Form\View\Helper\FormRadio extends Zend\Form\View\Helper\FormMultiCheckbox
You providing a custom multicheckbox helper to the view helper manager won't change that.
You'll have to create a custom FormRadio helper and have that extend your custom FormMultCheckbox class, then over-ride the formradio helper in your config, just as you did with formmulticheckbox
Related
I have required and installed "illuminate/html": "~5.0" like here: http://laravel.com/docs/5.0/upgrade and added it to the 'providers' and 'aliases' like there.
The problem is, I still get:
FatalErrorException in 65ad332c3ff984a4112203ba0538718c line 23:
Class 'HTML' not found
I have also tried to use Html; in the controller that 'makes' the view and in the view itself, but it did not help. Must I use the facade somewhere, or what could it be, that I am doing wrong?
I need this to use Html macros.
edit:
Seems to work now. I had to use Html in the view instead of HTML
The 5.0 docs are slightly misleading. If you are upgrading from a Laravel 4 app - you would be used to using HTML as the class.
So docs say to put this as your facade
'Html' => 'Illuminate\Html\HtmlFacade',
but if you want to continue to use HTML then it should be this
'HTML' => 'Illuminate\Html\HtmlFacade',
We have used tinyMCE at several places in our app just by adding a class to the text area or whichever element wherein we need to insert TinyMCE. But when I try to add tinyMCE to a newly created text area, it doesn't get loaded. But when I inspect the code, I Can find that the Jquery.tinymce.js script has been loaded. Kindly help me out.
Looks like you call the tinymce init function on pageload.
When you create a new textarea on the fly you should init that tinymce instance explicitly.
For this use:
tinymce.execCommand('mceAddControl', false, 'id_of_the_new_textarea');
I've started localizing my Symfony project but when I tried to use the __() function inside actions.class.php it came up with an error: Call to undefined function __(). The texts I have inside actions class are the form's labels and errors.
How can I localize these labels and errors if I am not allowed to use __() function? Is the simple translation into the catalogue enough? The same question applies for the Form classes.
Thank you.
in form $this->widgetSchema->setLabel('foobar'); will be automaticly translated: http://www.symfony-project.org/forms/1_4/en/08-Internationalisation-and-Localisation
the __() function usually works only in the templates with enabled i18n helper.
if you want to translate something in the action you will have to load the helper there. sfLoader::loadHelpers(array('I18n'));
I currently using ahDoctrineEasyEmbeddedRelationsPlugin to embed a Block form into a Page form.
All works well, but I'd like to hide the label of the embeddedRelation.
I've created a 'homepage-main-top' Block within the Page form in the admin, now when editting this Page, I now see 'homepage-main-top' is randomly appearing before the embedded block relation
Looking at the plugin docs, there doesn't seem to be anything relating to removing/hiding this:
http://imageshack.us/photo/my-images/197/relation.png
Does anyone know how to not display this?
Thanks
I've been struggeling with somewhat the same problem, only I needed to style the label instead of hidding / stripping it.
From what I've found out there is no simple way to manipulate the label of the embedded form, but I figured the following 'hack'.
The embedRelation method accepts a inner- and outer-decorator parameter. You can use these to wrap extra markup around the label and the embedded form. You can then use CSS to hide the label using a specific id / css class.
By openning tags in the outerdecorator and closing them in the inner decorator you can wrap the label in a tag (which is rendered inbetween the two). It is kind of tricky to make sure your HTML is still valid.
I know this is kind of a crappy solution but I haven't found a better way up until now.
Add this line to your parent form:
$this->widgetSchema['EmbeddedFormName']->setLabel(' ');
If the above doesn't work, try using the 'newFormLabel' option (from the plugin's documentation).
$this->embedRelations(array(
'RelationName' => array(
// ...
'newFormLabel' => ' ',
// ...
),
// ...
));
I am using SF 1.2.9 (with Propel ORM), to build a website. I have generated admin modules for some of my models. I want to modify the template used to display the Form because there are some fields that I dont want to display (but need) - example the 'slug' field in a form.
Since the templates are autogenerated, I cant make the changes there. How can I specify a template to use for rendering a form in the new/edit view?
In general, to override generated templates with your own, you just have to name your template same as generated one.
But looks like you do not need it. Hint: you can choose which fields to show in admin generator. Please consult symfony reference manual to realize how
To hide or remove fields from a form, I think you should check that link.
To sum up, the admin generator uses a ORM sfForm to render the edit action. So if you remove fields:
// lib/form/doctrine/ADoctrineClassForm.class.php
class ADoctrineClass extends BaseADoctrineClass
{
public function configure()
{
...
unset($this['field_name']
...
You can also change the widget used the render the field by redefining which widget to use:
//in ADoctrineClass configure method also
$this->widgetSchema['a_field_a_want_to_hide'] = new sfWidgetFormInputHidden()
I hope this helps.