$this->getRequest()->getParam('my_select_box');
This is what I use to get input values in controller in Zend Framework. When multiple selection is enabled with selectbox, this only brings one 'option.' How will I get an array of all selections user made?
I do not use Zend_Form, is there any way to achieve this?
You will need to name your element "my_select_box[]" and retrieve it as you do above.
Related
I am trying to extend an update view to include a list view of some related items below the edit form.
I have two models, Publishers and Volumes, which have a many to many relationship. What I am trying to do is this.... when a user clicks on the edit button for a publisher, I want them to go to a page with the standard edit fields, but also have a list view below the form that lists all of the volumes that are connected to that publisher via their relationship.
Is there an easy way to do this?
I hope this makes sense.
As #tabacitu mentioned, Backpack doesn't currently have an built in solution for this. That said, this could maybe work for you:
This would allow you to use all functionality of the nested list view including interacting with the entities without conflicting at all with the parent
Step 1, Build your normal CRUDs
Build out two normal CRUDs, one for Publishers, and one for Volumes
Step 2, Make a frameless layout
copy vendor/backpack/base/layout.blade.php
name it frameless-layout.blade.php
remove #include('backpack::inc.main_header') and #include('backpack::inc.sidebar')
Step 3, Make a custom list view
copy vendor/backpack/crud/list.blade.php
name it sub-list.blade.php
change the top line to #extends('backpack::frameless-layout')
Step 4, Make a custom field
Create a custom form field that contains an iFrame
Inside your custom field template, have it set the url of the iFrame to the "list" url of the related resource
You'd also need to utilize List Filters and a method for setting them dynamically so that the sub-list shows only the records related to the parent
Step 5, Configure and use the field
In your crud controllers, use the addField to add the the configuration for the new field and its related model
Indeed, there's no standard functionality to do that in Backpack. It's a pretty unusual way to do things. But it's not too difficult to achieve it.
If there aren't too many Vendors for one Publisher (as I expect it's the case here), I would keep it simple and NOT try to include the entire Backpack list view (with ajax, buttons, filters, etc) on top of the form. I would add a standard HTML table with the entries (and optionally buttons to Edit Vendor with target=_blank).
Here's how I would go about it:
In the Publisher CRUD, I would use a custom view for the Edit operation; you can do that using $this->crud->setEditView('edit_publisher_with_vendors') in your setup() method;
In that custom edit view (edit_publisher_with_vendors.blade.php in my example), I would copy-paste everything inside the edit.blade.php view that Backpack/CRUD is using, and add a table with the Vendors on top of the Edit form; notice you have the current entry as $entry in this view; since there's a relationship on the model, you would be able to check if it has vendors using $entry->vendors()->count(), and get the vendors using $entry->vendors.
Hope it helps.
I need to add validation for field:Phone to prevent adding text into phone field in SugarCRM 7.5
is it possible?
Thanks
You can achieve this functionality by different solutions:
Include JQuery Mask plugin and apply validation on all phone type fields.
Create custom field type for phone and apply validation.
Sugar has provided field validation for record view you can also get help from it link.
Here is related link to your question
Thanks Saad,
I did it by following solution:
Create a new custom field
Add my own mask input into _render() and initialize function
I added keypress event into custom field controller to prevent press invalid characters (symbols,....)
I added mustache files to showing proper values in edit,list view,...
I am new to grails and i got stuck with another issue.
I have two form's in my single GSP search.gsp and have two actions in my controller serach and results.
Now when i click on search button in one of my GSP file it takes me to search action which renders me search.gsp.At this time it should display me only first form in it. when i click results button in that form it will take me to results action.which has code line.
redirect(action:"search",params:[merchants:merchant,address:address])
this will take me back to search action but now i want to display 2nd form in search.gsp..
My problem is
how can i make search action once to run with out parameter's and once with parameter's?
how to determine in GSP from which action its been called?
with Advance thanks.
Depending on how different your forms are, you may want to consider having two separate GSP files (e.g., search.gsp and results.gsp). Use render(view:'action', model:[...]) to render a different view in the controller. This is often clearer that a single file with lots of conditionals.
Otherwise, you can find out the action using ${params.action}, so for example:
<g:if test="${params.action == 'search'}">
Text to show if the action is search
</g:if><g:else>
Text to show if the action is results
</g:else>
I would suggest you to separate your result page as template (_search.gsp), and render it from your result action. So that's how you will have different forms in different files.
By the way template is nothing but an ajax response, google it for detail about template in grails.
Is it possible to programatically disable form validation in MVC2?
I'm hoping there is some kind of command that I can put in a custom ActionMethodSelectorAttribute, making it possible to prefix ActionResults where I want form validation disabled.
The reason for this is that I have a form with multiple buttons, one button adds a new row to a child object of the model - which consequently creates a new row on the form.
This works fine, but validation is fired for the form each time "add" is pressed, and so the new fields flag up validation errors before the user has a chance to enter data.
I've found an alternative solution to this.
Rather than use multiple form buttons, I've used a custom html helper which produces a "Add" link.
This helper places the current Model in TempData and produces a Link to Add/{id}.
I'm not sure this is the cleanest solution, but it allows child elements to be added without validation firing. To tidy things up a bit, I specified the form as such:
Html.BeginForm(view, controller, new { id = Model.ID })
I am using the Zend Framework and have setup a normal Zend Form, what I want to try to achieve is to have a button (with some javascript) that says add more and it adds another drop down menu same as the one setup in the zend form (a clone of it).
basically when the button is clicked it adds another select box like so:
<select name="type[]"> ...</select>
I can do a copy of the multi select box with a different name and insert it in the DOM and catch the post from the controller outside of the Zend form but what I was wondering if there is a proper way to achieve this and be able to validate and populate the extra fields when editing a current data stored in db if there are any extra.. Any help is appreciated, thanks.
Well remember that in your controller if you have something like:
$this->form = new Form_Someform();
You can always do:
$this->form->addElement(etc...)
Right before using isValid() or populate.
So in your controller when someone submits the form, when creating your form object you could check if any select were created dynamicaly and then create corresponding Zend_Elements and just validate against that.
Also when you reload that form you just create elements depending on whats in your database.
You could also use the forms constructor to pass in an array of selectboxes and create then right there too. Thats what I do.
The important things to remember is that you have control on the constructor and on the form object between its creation and the use of the populate() and isValid() functions.
Hope this helps.