Laravel: A field that lookup another field from different table - laravel

I use Backpack for Laravel.
I know that to add a field, we can use:
CRUD::addField(['name'=>..])
But, I don't know how to add a field that lookup another field input from different table to show a lookup value.
Please look at the illustration below.
Thanks.
Edit:
I found a temporary solution to this, but not effective.
Reference: https://backpackforlaravel.com/docs/4.1/crud-how-to#add-a-select2-field-that-depends-on-another-field
With select2_from_ajax you still have to select the option (even its just one option left), meanwhile what I really want is its automatically select that one option.

It's depends on what you need to do. You can use relationship field and show a select with the list of user. If you really wanna do it like this. You can probably make an ajax request to show it. In that case you ll need to use a custom view for the edit or the create view.

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.

CakePHP - use aliases instead of column name in labels

I have some columns with long and unfriendly names, which I want to edit app-wide in dynamic forms.
Is there a way to add "alias" or "title" to a column, so that echo $this->Form->input('icantshowthis'); will echo something else than "icantshowthis" as the label content?
I am aware to virtual fields and don't want to use them, since it seems like wrong practice. (this is a view issue)
pretty please??
You are looking for Secury in Forms for CakePHP, this obfuscate the real field names by hasing the name attributes in inputs, and may abstract that to the controllers that receives the data.
The disvantages are when you need to insert fileds that are not part of your models.
Hope it help!

How to create a help-form in FormsBuilder?

I am required to make a form which will contain important keywords and their description, with the possibility to search between the words. It is loaded from the Help menu and it is designed to give the users detailed help informations about other components. (Just like every application's Help menu)
I only used forms to query tables, and I was wondering, what is the correct way to achieve this? Does Oracle support any feature that would auto-generate a help-form based on my 'Help' inputs from Property Palettes? or do I have to manually write data into a canvas? if so, how can I search through it?
I considered creating a table and writing help informations in it, but I don't think that is the correct way.
Oracle Forms, unfortunately, does not give you programmatic access to values stored in property palettes, so your solution will need to be custom made.
Create a table, e.g. HELP_TOPICS (keyword, help_text), add a list item that contains all the keywords; when a user selects a keyword, query the table to find the help text, and set the value on a display-only text area item on the page.

MCV3: View to edit entity has to hold every column?

I got a silly general question...
If I generate a strongly typed view of an entity and chose "edit" as scaffolding, then the view does contain every column for that table. Changing and saving the values via setting it modifierd and call db.SaveChanges() does work in the controller. So far, so good.
But if I remove just one of that columns inside the view, then saving doesn't work anymore.
Is there a rule describing this? Is it only possible to make view with every column when wanting to save the model later on? I don't want to make 90 of 100 columns "hidden"...
PS: When editing a value in another table which is connected via Foreign Key (like customer.address.STREET) saving also does not work. Does everything of the entity ADDRESS has to be inside the view? I really don't get that.
Besides that: If I create my own ViewModel containing two entities: Do they also have to hold every column of both entities? This would be a whole bunch of traffic...
Answer is: You should not use the .Modified state. Instead using the UpdateModel method works fine without every field.

database driven form controls

How to do databse driveen jsp page,
Suppose i have 5 text fields,if user wants to put one of the form field as select box.JSp should identify and return the select box if it define in db as select box.
I dont know how to achieve this,can anyone suggest this.
Regards,
Raju komaturi
There are multiple tasks if you want to do this completely. The world at large has not gone this way and so there are not many tools (if any) for this. But basically here are the main ideas.
1) You want a "data dictionary", a collection of meta-data that tells you what the types and sizes of each column are, and the primary and foreign keys are.
2) For your example of "knowing" that a field should be a drop-down, this almost always means that column value is a foreign key to another table. Your code detects this and builds a listbox out of the values in the parent table.
3) You can go so far as to create a complete form generator for simple tables, where all of the HTML is generated, but you always need a way to override this for the more complex forms. If you do this, your data dictionary should also have column descriptions or captions.
There are many many more ideas, but this is the starting point for what you describe.

Resources