Drupal 8 YAML Form Module: Populate Select Element - yaml

I'm a newbie in Drupal and I'm trying to create custom forms in Drupal 8 using 'YAML Form' module:
https://www.drupal.org/project/yamlform
I have added some 'select' elements with some custom options from the Form elements page provided by the module, but I don't find the way to populate these elements from database.
How can I do it? Step by step if possible, please.
Thanks in advance!

I don't know if it's the best way to do it but it works for me:
I've created a custom module and in the '.module' file I've implemented the hook hook_yamlform_options_YAMLFORM_OPTIONS_ID_alter() when the part YAMLFORM_OPTIONS_ID is the ID of a custom set of options I've added in the Options page (admin/structure/yamlform/settings/options/manage).
The code of the hook, basically, gets data from database and sets it in the $options array with the desired keys and values.
Then when I access to the Options page again, in the row of the new custom set of options, the column ALTERED has the value 'Yes'. Click to 'Edit' this row and then click to 'Reset' button. The result is that the options value/text table is updated automatically with the data returned from database.

Related

Vuetify - dynamically create a form with v-text-fields + CRUD - v-model issue

in a Vuetify project I would like to dynamically create all the required fields to perform CRUD Actions:
I prepared a working sample here:
https://codepen.io/jslab-it/pen/KKqyBdX
Everything's working not bad, but when I click on the edit button, the dialog appears but fields are not populated:
I assume that problem is that v-model is "calculated":
:v-model="'editedItem.'+f.name"
in fact in the last field that is not generated but hardcoded and thus has
v-model="editedItem.calories"
the field is automatically populated.
I tried also using a computer property for editedItem, but without success
Can suggest if it is possible and the right path?
Thanks
You can use editedItem[f.name], which is a standard way to access dynamic property in js.

Show form field based on item list

Is it possible to display an input form field based on the value of a select menu? Or is this something I'd have to do in javascript/jquery?
My list is pulled from the database if that changes anything.
If you want to make this happen during the form filling, yes you probably will need to use Ajax (via vanilla Javascript or jQuery), if you need to query your database as options are selected, or just CSS: http://www.coderanch.com/t/594720/HTML-CSS-JavaScript/Show-Hide-text-box-select, if you populated via database but don't need to check it again for changes.

Cannot set selected elements for the list module on Joomla Fabrik extension

I am using free version of Fabrik extension on Joomla. Both my Joomla and Fabrik are the latest version
I have already done with the Fabrik structure part such as create the form, elements, group, list, and set the form order, validations, appearance, and make them all works. Any registered user can submit the data using the form and it'll be stored into a table on the database
On the front-end, the idea is the user can view two different list view modules through his/her profile, a private list and a public list
Module A lists only entries submitted by the user. The list show the whole entry's data
Module B lists all of the entries submitted by everyone. The list show only selected data from selected field from each entry
This where the problem came from. When I gonna create a module for the list view (Fabrik List Module)
Module Manager > New > Fabrik List Module > Advanced
After I set the title and the list, when I clicked on the 'Select' button for attribute 'Elements', it just response me like I just clicked on 'Cancel', and redirect me to the modules list table instead. If it is just an unfixed bug, I can do nothing about it, but I guess it'll be a lot easier if I can just set something directly using database admin
Finally, after some little hacking, i've succesfully figured it out. Go to [pre]_menu.params (for menu item) or [pre]_modules.contents (for module), and you'll see some json like this
{"calculations":"0","listlayout":"bootstrap","resetfilters":"0","list_elements":"null", ....}
Just replace list_elements value from "null" to this
"{\"show_in_list\":[...]}"
[...] contains the list of elements id (inside table [pre]_fabrik_elements) we want to select them on module view, for example [1,2,3,4,5]
updated :
It's very unpractical solution to just modify the joomla data directly on database. Actually, especially in similar case to mine (sure it is a bug), you can select the elements for a list view (as asked) by simply creating a new separated list apart from the auto generated list which is generated by default on form creation.
That new list will automatically generate new set of elements with new ID based on database table structure, and plus they will not shared their setting with the default list. Alter the default list should definitely be avoid as it will totally change the behavior of the form
On the new list, you can simply un-"show in list" any elements you don't want to show, and create either menu item or module linked to the new list. This is also the best way if you want to alter the list displaying such as change the list header field title, change the list description, or join others elements to the list

Magento custom fields

I have added new custom fields (checkbox) in catalog\category. using Installer.
it appears in a new tab as i want but can't save the value checked,
if anyone can help me to save the custom Checkbox Value.
It sounds like you have added an attribute using the install script, and although Magento will display a checkbox the data won't be saved, even if you are using the eav/entity_attribute_source_boolean source model.
I would consider using a select rather than a checkbox. However if you require a the input to be a checkbox, you will need to create your own input & source model to handle it.

How do I create an editable field with a Save button on Magento Admin's Order detail page?

I've already created a custom module that overrides the sales/order/view/tab/info.phtml layout file and creates a new field in the sales_flat_order table. Now I need figure out how to add a text input field to the order page:
The save button doesn't necessarily need to be right near the custom field and the field doesn't need to necessarily appear right where I put it in the graphic. Bottom line is, the administrator needs to be able to edit my new custom field in the admin.
What is the best way to do that?
Look at Comments History block
implementation - class Mage_Adminhtml_Block_Sales_Order_View_History, its template \app\design\adminhtml\default\default\template\sales\order\view\history.phtml and Mage_Adminhtml_Sales_OrderController::addCommentAction(). You should create similar block class with similar template and create controller with action which will save form data to your db field.

Resources