Styling the form block (custom template)
Permalink
I'd like to style the form block. I *thought* that I could do this by creating a custom template but it looks like the styling for the form block is in:
However, if I change this then all the other forms in my site will be styled the same way?
Is there something I'm missing here?
concrete>core>controllers>form_minisurvey.php (inside of the loadSurvey method)
However, if I change this then all the other forms in my site will be styled the same way?
Is there something I'm missing here?
Okay I have a another question.
I have a "controller" folder outside of the concrete folder, but I don't have a "core" folder.
form_minisurvey.php is in
concrete>core>controllers>form_minisurvey.php
Does this mean I can't / am not supposed to override the file?
I get how to override concrete controllers but this file is in concrete> core > controllers NOT concrete > controllers (generally if I want to override a concrete controller I just make a copy in my controllers folder, right?)
SO, do I just create a core folder, put "controllers" in the "core" folder, and put my form_minisurvey.php controller class there?
I have a "controller" folder outside of the concrete folder, but I don't have a "core" folder.
form_minisurvey.php is in
concrete>core>controllers>form_minisurvey.php
Does this mean I can't / am not supposed to override the file?
I get how to override concrete controllers but this file is in concrete> core > controllers NOT concrete > controllers (generally if I want to override a concrete controller I just make a copy in my controllers folder, right?)
SO, do I just create a core folder, put "controllers" in the "core" folder, and put my form_minisurvey.php controller class there?
No there should only be one core folder.
If you copy the form block controller as described above then it should be sufficient as that controller extends the *core->controllers->mini_formsurvey* controller so you can override the methods you need in that file
If you copy the form block controller as described above then it should be sufficient as that controller extends the *core->controllers->mini_formsurvey* controller so you can override the methods you need in that file
Ahh I see thanks.
Also I had to disable the "Overrides Cache", looks like there was an identical question here (duh)
http://www.concrete5.org/community/forums/customizing_c5/override-c...
Also I had to disable the "Overrides Cache", looks like there was an identical question here (duh)
http://www.concrete5.org/community/forums/customizing_c5/override-c...
I'm getting an error on
I think it's because $this is the MiniSurvey class, *not* the FormBlock controller class?
if($this->get('surveyName')!='Whatever name you use')
I think it's because $this is the MiniSurvey class, *not* the FormBlock controller class?
Sorry I got it wrong by trying to read the controller file too fast. Basically the MiniSurvey and the Concrete5_Controller_Block_FormMinisurvey are different classes which is why it does't work.
This in fact makes life a bit easier, as you can do the following instead of the previous method:
1) In /models create a new class (call it what you like) e.g. custom_mini_survey.php, do this in that class:
Within that extend the loadSurvey method as needed (no need for the block name checking anymore).
2) Create a custom view template for your form in /blocks/forms/templates
Copy the /concrete/blocks/form/view.php file as a starting point, but make sure you rename it to something else e.g custom_view.php
3) At the top of your custom view, change
to
4) Set the form to use the Custom View template
This should work (untested but seems logical) and if the custom view doesn't recognise the CustomMiniSurvey class you might have to load it at the top of your view template using Loader::model('custom_mini_survey')
This in fact makes life a bit easier, as you can do the following instead of the previous method:
1) In /models create a new class (call it what you like) e.g. custom_mini_survey.php, do this in that class:
<?php class CustomMiniSurvey extends Concrete5_Controller_Block_FormMinisurvey { }
Within that extend the loadSurvey method as needed (no need for the block name checking anymore).
2) Create a custom view template for your form in /blocks/forms/templates
Copy the /concrete/blocks/form/view.php file as a starting point, but make sure you rename it to something else e.g custom_view.php
3) At the top of your custom view, change
$miniSurvey=new MiniSurvey($b);
to
$miniSurvey=new CustomMiniSurvey($b);
4) Set the form to use the Custom View template
This should work (untested but seems logical) and if the custom view doesn't recognise the CustomMiniSurvey class you might have to load it at the top of your view template using Loader::model('custom_mini_survey')
You don't say what exactly you want to style, but depending on what it is, this might be helpful to you:
http://www.concrete5.org/marketplace/addons/form-tableless-layout/...
http://www.concrete5.org/marketplace/addons/form-tableless-layout/...
I think that's probably it, and I think I've used that addon before (duh).
I keep forgetting how styling the form block is different from the other blocks...is this getting changed at any point?
For the addon, I have one question, can I use more than one custom template?
I keep forgetting how styling the form block is different from the other blocks...is this getting changed at any point?
For the addon, I have one question, can I use more than one custom template?
I have no idea what the core team's plans are, but they seem to never go back and clean up existing blocks, so I'd guess "no".
And yes, you can have as many custom templates as you want. Just create more files in the /blocks/form/templates directory (and choose between them by clicking on the block while in edit mode and choosing "Custom Template" from the popup menu.
-Jordan
And yes, you can have as many custom templates as you want. Just create more files in the /blocks/form/templates directory (and choose between them by clicking on the block while in edit mode and choosing "Custom Template" from the popup menu.
-Jordan
Copy the methods you want to override from concrete/core/controllers/blocks/form_minisurvey.php into your class
This will mean that all your blocks will use the markup generated by your new methods.
If you want to use the default styling on all forms except for this one then you can always give a block a particular name (using the "Form Name" attribute under "Options") when adding the form and then add a check at the top of your override method so for example if you were overriding the loadSurvey method you might have something like this: