Dynamically add input boxes to an edit form in joomla 2.5 - joomla

I followed this tutorial on how to build a component for joomla 2.5, but now I am stuck.
What I want to do:
Besided thoses field defined in admin\models\forms\.xml I want to dynamically add form fields. The field list should be read from database.
I have a:
main table #__tours(id, title),
field list table #__tourfields(id,lable,description,position)
field value table #__tourfieldvalues(tourid,fieldid,fieldvalue)
#__tourfields contains a list of additional fields, that the user may want to specify for each entry in #__tours. #__tourfieldvalues would contain the values for the additional fields.
So now I need to figure out how to add input boxes to the edit form for each row in #__tourfields, read the values in #__tourfieldvalues for the currently to display entry of #__tours.
How can I do this?

This is very complex question. Subject to small book :)
In general you have to create class for every field type and initiate this class for every field in #__tourfields. This class have to extend JFormField and have getInput() method overridden.
Then in cycle you fetch your fields.
Something like this. But I believe you have to have more specific question. This one sounds like "How to create CMS like Joomla from scratch?"

Related

How to add another table column in searchable array in nova?

i am getting data from different different tables and i displayed all those in one section that section contains search button also, i want to add another resource field as a searchable item in nova ,i am trying to add based on the relation of the particular table but it's throwing an error undefined column, How to add please help..
public static $searchable=['id','name','account.type'];
Basically, the search by relationship is not possible through Nova.
A package well made for your needs is this one: LaravelNovaSearch
This package includes both relationship search but also has other useful features making the search much more comprehensive.
Another package, which I have not personally tested, but which seems to be useful for your needs: NovaSearchRelations
My advice is to use LaravelNovaSearch, more maintained and more complete.

Odoo Pass a dynamic list to View

I want to filter many2one field using a domain in the create view. What I'm trying is send a list to the view as a functional field and use it in the domain. (That list will change according to user) It will look as follows,
<field name="filter_ids" invisible="True"/>
<field name="department_id" domain="[('id','in',filter_ids)]">
What type of functional field should I use for this purpose?
Or any idea to dynamically change (one user to another) the domain of a many2one field?
I tried many ways using on_change, fields_view_get and so many others. On_change calls on load but it doesn't filter values onload. fields_view_get add the domain but it apply for all form views including update view which should not happen according to the requirements. please help :)
1-You can use fields_view_get then
2- set
so you don't get the field in your edit view
3- use another field which should behave as you want it on the edit view

Joomla Component Dynamic Custom Field based on other Field Value

I am creating a new Joomla Component. I am able to create custom fields for the component backend forms - but I am not able to create Dynamic Custom Fields.
What I would like to do is have a field that is dynamical populated based on the value of a previous field. The easiest way to explain this is the simple country,state,city breakdown.
Field 1 = Country
Field 2 = State (Based on what the user selected as as Country in Field 1)
Field 3 = City (Based on what the user selected as State in Field 2)
The fields would of course need to be refreshed, reset as the user picks a different country etc.
The data to populate the fields would also all need to come from a database based on the previous fields value.
I am guessing this needs to be done via ajax or javascript or something? But wondering if there is an official way? Especially since there are database calls involved.
Please let me know if there is anything I can explain better..
David
I ended up just creating text fields but then validating the input to make sure the values added are correct.

Binding one NSSearchField's text to two different controller objects

I have two different NSArrayControllers but I'd like to use the text of one search field to filter them both. The predicate would be different for each controller. Is it possible? Right now I can only get it to filter one array controller at a time.
YES this is possible.
You can do it as : This Stack Overflow answer by me shows how to do for one table and ArrayController.
For multiple you just need to add a new predicate, which will say as Predicate2. Please refer the screen shot:
Here Teacher and Student class contains a property name. However yo can have different property name. Also I am filtering only on one column or property you can search it for multiple columns/properties, for this refer the above link.

Changing the model's attributes - adding or removing attributes

I am working on a MVC3 code first web application and after I showed the first version to my bosses, they suggested they will need a 'spare' (spare like in something that's not yet defined and we will use it just in case we will need it) attribute in the Employee model.
My intention is to find a way to give them the ability to add as many attributes to the models as they will need. Obviously I don't want them to get their hands on the code and modify it, then deploy it again (I know I didn't mention about the database, that will be another problem). I want a solution that has the ability to add new attributes 'on the fly'.
Do any of you had similar requests and if you had what solution did you find/implement?
I haven't had such a request, but I can imagine a way to get what you want.
I assume you use the Entity Framework, because of your tag.
Let's say we have a class Employee that we want to be extendable. We can give this class a dictionary of strings where the key-type is string, too. Then you can easily add more properties to every employee.
For saving this structure to the database you would need two tables. One that holds the employees and one that holds the properties. Where the properties-table has a foreign-key targeting the employee-table.
Or as suggested in this Q&A (EF Code First - Map Dictionary or custom type as an nvarchar): you can save the contents of the dictionary as XML in one column of the employee table.
This is only one suggestion and it would be nice to know how you solved this.

Resources