CakePHP Master/Detail Form - simple Issue - forms

I'm building a simple master/detail edit form using Cake, but can't get the values from the details records to populate the form.
Workorder -> Master
WorkorderIssues -> Detail
DebugKit tells me the data is being returned properly from both the master and detail tables.
I can populate the form with master data just fine using:
Form->input('workorder_ref');?>
..but the same approach doesn't work for the detail data:
Form->input('WorkorderIssues.issue_owner');?>
Post data:
Workorder(array)
workorder_id 1
workorder_ref 9212
WorkorderIssues(array)
0(array)
issue_id 1
issue_workorder_id 1
issue_owner shaun
I would appreciate some help..it's probably something simple I'm overlooking.
Many Thanks,
Shaun

The context of the question was an edit form for master/detail records with a hasMany association from Workorder to WorkorderIssue.
Master data from the request can be accessed as usual like:
form->input('fieldname'); There is only one record.
In my example, the master data (Workorder) is accessed as:
form->input('workorder_num');
Multiple records from the Associated/detail data can be accessed from the request as:
form->input('workorderissue.0.issue_description');
form->input('workorderissue.0.issue_owner');
form->input('workorderissue.1.issue_description');
form->input('workorderissue.1.issue_owner');
form->input('workorderissue.2.issue_description');
form->input('workorderissue.2.issue_owner');
...the integer index (0,1,2) represents the array element each record is stored under.

Related

How to update rows / set row data in server side row model type in ag grid?

My data model looks like this. Array of objects containing title and created_date.
{
title : String
created_date: Date
}
I have defined a column definition which only renders the title. However, I'd like to sort the rows based on the created_date, without creating a created_date column. There will be an external button detached from the table, which will call the api to get the data. I am using row model type serverSide. I have the sorted data from the backend. I just need to update the data / refresh the data. How can I achieve this ? I have so far tried setRowData(updatedRows). but its giving me an error saying cannot call setRowData unless using normal row model. Is there any way to update my rows in this serverSide row model type settings ?
Calling this.gridApi.setServerSideDatasource(myDataSource); and passing in your dataSource will do the trick. Check here for details

Does ordering in Sequelize default to 'updateAt'? Can I have "no" Ordering?

Newbie to web development here - using a postgres db, with Sequelize.
So I have a model called "Form" that hasMany of a model called "Section".
When I create a Form, 4 associated sections are created and associated with the Form.
I'm using the following association method of Form.getSections to successfully retrieve an array of sections.
When I edit a Section however, the order of the item in the table changes, so when I Form.getSections again, the Section I edited is the last item in the array. It appears that by default, Sequelize does order: [['updatedAt', 'ASC']] for this method.
My questions are:
Is this true?
Is there a simple way of stopping this ordering from happening?
How do I keep my Sections in place?? Is there such thing as null ordering?
Let me know if some actual code will help with this!

Can you control the print order of Access form with subforms?

I have a form in Access 2007 with 2 subforms. Each one has it's own table. All 3 tables have a primary key to link on. The 2 subforms can be linked by the primary key and a second field. Users want to print the form, rather then a report, to review the record data. When the form prints the order is as follows:
Main form, [subform1]![record1], [subform1]![record2], etc, [subform2]![record1], [subform2]![record2], etc, last page of the main form.
How do I force the form print order to be:
Main form, [subform1]![record1], [subform2]![record1], [subform1]![record2], [subform2]![record2], etc, last page of the main form.
I've tried setting up the table relationships and checked all the Master-Child links. The form navigates through records correctly. I've also looked at print options but didn't see a solution there either.
You will need a query where you join the master table with the two subtables.
Then apply the requested order and create new form for printing.
Still, a report would be better. Remember to remove any sorting from the query and specify that in the report.

cakePHP single form, two tables, multiple records

There are two tables:
poducts [id, name, etc..] and specs [id, product_id, spec_name, spec_value],
I'm using a form to edit the product (/products/edit/332 for example)
In the form i wan to add (it's associated and i can access it in the view) the specs. which are a list of records from the specs table.
is it possible to create the specs as inputs in the same form?
also, i would like to enable the feature of "add new spec".
thanks
For saving related model data, you can use saveAll:
$this->Product->saveAll($this->request->data);
And your inputs in Product form:
echo $form->input('Spec.0.spec_name');
echo $form->input('Spec.0.spec_value');
If you need more inputs, just increase the 0 value.
More information: http://book.cakephp.org/2.0/en/models/saving-your-data.html

APEX - Creating a page with multiple forms linked to multiple related tables... that all submit with one button?

I have two tables in APEX that are linked by their primary key. One table (APEX_MAIN) holds the basic metadata of a document in our system and the other (APEX_DATES) holds important dates related to that document's processing.
For my team I have created a contrl panel where they can interact with all of this data. The issue is that right now they alter the information in APEX_MAIN on a page then they alter APEX_DATES on another. I would really like to be able to have these forms on the same page and submit updates to their respective tables & rows with a single submit button. I have set this up currently using two different regions on the same page but I am getting errors both with the initial fetching of the rows (Which ever row is fetched 2nd seems to work but then the page items in the form that was fetched 1st are empty?) and with submitting (It give some error about information in the DB having been altered since the update request was sent). Can anyone help me?
It is a limitation of the built-in Apex forms that you can only have one automated row fetch process per page, unfortunately. You can have more than one form region per page, but you have to code all the fetch and submit processing yourself if you do (not that difficult really, but you need to take care of optimistic locking etc. yourself too).
Splitting one table's form over several regions is perfectly possible, even using the built-in form functionality, because the region itself is just a layout object, it has no functionality associated with it.
Building forms manually is quite straight-forward but a bit more work.
Items
These should have the source set to "Static Text" rather than database column.
Buttons
You will need button like Create, Apply Changes, Delete that submit the page. These need unique request values so that you know which table is being processed, e.g. CREATE_EMP. You can make the buttons display conditionally, e.g. Create only when PK item is null.
Row Fetch Process
This will be a simple PL/SQL process like:
select ename, job, sal
into :p1_ename, :p1_job, :p1_sal
from emp
where empno = :p1_empno;
It will need to be conditional so that it only fires on entry to the form and not after every page load - otherwise if there are validation errors any edits will be lost. This can be controlled by a hidden item that is initially null but set to a non-null value on page load. Only fetch the row if the hidden item is null.
Submit Process(es)
You could have 3 separate processes for insert, update, delete associated with the buttons, or a single process that looks at the :request value to see what needs doing. Either way the processes will contain simple DML like:
insert into emp (empno, ename, job, sal)
values (:p1_empno, :p1_ename, :p1_job, :p1_sal);
Optimistic Locking
I omitted this above for simplicity, but one thing the built-in forms do for you is handle "optimistic locking" to prevent 2 users updating the same record simultaneously, with one's update overwriting the other's. There are various methods you can use to do this. A common one is to use OWA_OPT_LOCK.CHECKSUM to compare the record as it was when selected with as it is at the point of committing the update.
In fetch process:
select ename, job, sal, owa_opt_lock.checksum('SCOTT','EMP',ROWID)
into :p1_ename, :p1_job, :p1_sal, :p1_checksum
from emp
where empno = :p1_empno;
In submit process for update:
update emp
set job = :p1_job, sal = :p1_sal
where empno = :p1_empno
and owa_opt_lock.checksum('SCOTT','EMP',ROWID) = :p1_checksum;
if sql%rowcount = 0 then
-- handle fact that update failed e.g. raise_application_error
end if;
Another, easier solution for the fetching part is creating a view with all the feilds that you need.
The weak point is it that you later need to alter the "submit" code to insert to the tables that are the source for the view data