Defining a custom find form with fields from more than one t

A place for users and developers of the Xataface to discuss and receive support.

Postby Markus » Wed Jul 11, 2007 3:48 am

Hi Markus,

>

If the order= isn't working, then I'll have to look into this..

>

As far as the dummy relationship goes, just try making a relationship (on any table) such that the __sql__ attribute of the relationship is your SQL query. Then you can try adding new records to this relationship. This won't really help for editing though.

>

The next version of dataface has quite a few new features for being able to edit fields from multiple tables on a single form. It will be available in the next couple of months.

>

_Steve



Hi Steve,

thank you for your answer. I have a few more qiuestions though. If you can mananage to get the order= thing running for the external fields from the JOIN Query would be great. Please tell me how it goes on with this topic. And of course I am interested in the "edit fields from multiple tables on a single form". Seems to be the "killer-app" for my current problem.

Back to my custom find form. I am not really sure about it. I would create a custom form like you suggested before but where exactly should I place this form. I think I shall write a custom template for this and place it in the templates folder of my app?
The best would be to have the custom find form before my details and list view table. How can I reach that?

Currently I have something like:

{use_macro file="Dataface_Main_Template.html"}
{fill_slot name="main_column"}

























Hersteller:
Serie/Baureihe: Fahrzeug/Typ:



Kraftstoff: Umrüstsystem: Ereignistyp:



Ereignis: Bundesland: Betrieb:



   

{/fill_slot}
{/use_macro}

which should be my custom find form.

Then second I would have to define a custum action, right? I am a little bit puzzled how it all works together. Do I have to use actions.ini?
Where do I place the php-Code for my custom find form? I think it has to go in a folder called pages, right? I didn't have such a folder before so I created one and put my custom_find.php there. Why not into the actions folder of my app?

I tried this already but could not really get something out of it. Maybe some hints?

Thank you

Markus
Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm

Postby Markus » Wed Jul 11, 2007 3:49 am

Maybe I should use


{use_macro file="Dataface_Main_Template.html"}
{fill_slot name="main_column"}

























Hersteller:
Serie/Baureihe: Fahrzeug/Typ:



Kraftstoff: Umrüstsystem: Ereignistyp:



Ereignis: Bundesland: Betrieb:



   

{/fill_slot}
{/use_macro}
Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm

Postby Markus » Wed Jul 11, 2007 3:58 am

Sorry but the code in my last two postings is not displayed correctly. I can see it only when I look into source code of the posting.
How to avoid this? Currently I use Firefox 2.0.0.4 and tried all of the three Editors on your site. Sometimes it works, sometimes not.

Please have a look into the last but second posting to see my relevant questions.

Markus
Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Wed Jul 11, 2007 12:33 pm

Hi Markus,

The easiest thing to do might be to just place your custom find form inside the find tab for umruest table. There is a block named "before_find_form" that you can insert content into. You just have to implement the block__before_find_form() method in your umruest delegate class.

e.g.
function block__before_find_form(){
df_display(array(), 'custom_find_form.html'); // assuming you called your template custom_find_form.html
}

Then your form would show up just before the existing find form.
And just to make sure your form directs dataface to the right place, make sure that you have hidden fields to keep track of the table and the action.

e.g.


Hope this helps..

oh and since you'll be displaying your form inside a block, you won't need to use the {use_macro} tag in your template.
i.e. get rid of the
{use_macro file="Dataface_Main_Template.html"}
{fill_slot name="main_column"}

and the corresponding closing tags from your template.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Markus » Wed Jul 11, 2007 2:54 pm

Hi Steve,

this works perfectly if I have inputs instead of selects in my form. If I put some "given values" in there, it works great. Thank you for your help.

But I would like to have selects and to fill them with valuelists so that the user can choose the given values. So I think, I have to make querys to get the valuelists into the selects.

Where would I put the querys e.g. the php-code? Into my custom_find_form.html? Or somewhere else?

I will try but maybe you have an idea.

Markus
Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm

Postby Markus » Wed Jul 11, 2007 3:20 pm

Hi Steve,

this is just a comment to my last posting.

OK that could not work because I cannot put php-code into the custom_find_form.html. But where to put it then?

I had a look at the SearchForm.php but would never be able to customize it. So what can I do?

Markus
Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Wed Jul 11, 2007 3:53 pm

Why do you need to put php code in your form? You should be able to just pass the proper inputs back to dataface and let dataface take care of the rest.
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Markus » Wed Jul 11, 2007 4:20 pm

Hmmh,

did you read the last but second posting? I mean, I want to have kind of DYNAMIC valuelists in my SELECT fields of my custom find form.

I want to read out the already inserted values for e.g. Hersteller, Serie/Baureihe, Fahrzeug/Typ and so on...

As I said if I have inputs instead of selects and put in the values I know that are in the database the custom find form works well.

But how to get the already inserted values out of the database and into the select fields of my custom find form?

I think there is a pretty easy solution but maybe I am too tired now to see it. Understand me right: I would very much like to let dataface take care of the rest..

And another question is how to have my custom find form INSTEAD of the standard find form and not in addition before it?

I can comment it out in Dataface_Find_View.html but then it doesn't turn up in all of my tables.

It is pretty late here but if you have some spare time right now...

Thanks for your answers

Markus
Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Wed Jul 11, 2007 4:28 pm

Sorry, missed the first post.

If you just need to calculate valuelists, you can do that inside the block__before_find_form() method, then pass the desired values into your template.

e.g.

function block__before_find_form(){

$table =& Dataface_Table::loadTable('umruest');
$myvalues = $table->getValuelist('myvaluelist');
df_display(array('myvals'=>$myvalues), 'my_find_form.html');
}

Then in my_find_form.html, you can use the values in the myvals array:



Hope this helps.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Wed Jul 11, 2007 4:31 pm

Oh.. to answer the question about replacing the default find form with your own, you just use a different block.

I.e. instead of using the before_find_form block, you use the find_form block.
i.e. implement the block__find_form() method.

To see what blocks are available on the find form, check out the Dataface/templates/Dataface_Find_View.html template. You'll see the blocks and slots clearly marked.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Markus » Wed Jul 11, 2007 4:44 pm

Steve, you are great. I will try tomorrow and will tell you about my results then.

Have a nice evening over there. I have to go to bed now.

Markus
Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Thu Jul 12, 2007 2:22 am



> <option value="{$mykey}">{$myvals}<option>


Whoops. This should be:
Code: Select all
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Markus » Mon Jul 16, 2007 2:36 am

Hi Steve,

finally it worked. I now have a custom find form integrated into my app where I can search my table umruest over the relevant fields in there plus the fields I load into the list and details view with the JOIN query in fields.ini of that table.

All the valuelists I need are defined in the valuelists.ini of the table umruest.

Thanks a lot for your help.

Now I would like to customize my app with two different buttons for saving records in thew new record and edit record views of the tables betriebe and vehicles. Beneath the standard save button I would like to rename to "save and exit" I would like to have a button called "save and go on" (something like that).

The purpose of the "save and go on" button should be the following:

There are three tables in my app which are related and should be filled in a certain order one after the other. Something like Step1-Step2-Step3...

I have the table betriebe which records should be filled first, than I have vehicles as the second and umruest as the third step.

the primary auto increments of betriebe (bid) and vehicles (vid) are linked to foreign keys in umruest (B_ID, V_ID). It would be great when the user has filled in a new betriebe record and clicks on the "save and go on" button he should get the new record form of vehicles and keep the primary key of the new record in betriebe and when having filled in and submitted a new vehicles record also the primary key of vehicles somewhere in an array. When the user then clicks on "save and go on" in vehicles he should become the new record form of umruest with the primary keys of the new record in betriebe and vehicles ALREADY FILLED in the foreign key fields of umruest table.

The same should happen when the user clicks on an existing related record of umruest in either vehicles or betriebe in edit view. That means with the "save and go on" button he should either get a new record form or the already existing related record in table umruest in edit view.

If the user clicks "save and exit" the standard save record functions should be available.

I wonder wether I need a relationship between betriebe and vehicles, which I don't have right now?

Where to start to get the second button in and then how would I proceed to reach this aim?
I think I have to use triggers for that but maybe you can give me some hints how to start.

Thank you

Markus
Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Wed Jul 18, 2007 10:57 am

Hi Markus,

Sorry for the delay in reply. A couple of things:

1. Currently there is no easy way to add another submit button to a form.

2. You can achieve your desired flow control using after_action triggers, and passing GET parameters to the edit form to let it know the context.

e.g. If you pass a GET parameter to the edit form (or any page) that begins with a single '-', it will be maintained through subsequent requests.

e.g. If you pass a parameter like "-wizard=Wizard1" to the edit form, this will be maintained across requests. Why is this helpful, you may ask? This is helpful because it will allow us to keep track of the context in which the user is filling out an edit form.

e.g. if you create a link like "index.php?-table=betriebe&-wizard=Wizard1&id=10", then the user will be directed to the edit form for a record with id 10 in the betriebe table - but it will store the -wizard variable in a hidden field and pass it in the request.

You can then implement the after_action_edit trigger, and check to see if you are currently in the "Wizard", and forward to the next form to be edited if you are.

e.g.
function after_action_edit(){
if ( @$_REQUEST['-wizard'] == 'Wizard1' ){
header("Location: ");
exit;
}
}

See http://framework.weblite.ca/documentation/how-to/after_action_triggers for more info about after_action triggers.

In fact, you could even add little next and previous buttons/links after the form by using the after_edit_form block and a little bit of javascript to submit the form:

e.g.
function block__after_edit_form(){
if ( @$_REQUEST['-wizard'] == 'Wizard1' ){
echo '';
}

This strategy will require some refining and thought to make it work smoothly... but it is the right direction towards what you want.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Markus » Fri Jul 20, 2007 4:42 am

Hi Steve,

I am not quite sure if I get you right this time. I think I want to do this with new records instead of existing records first. So I tried the following in my DelegateClass of the table betriebe:

function after_action_new(){
if ( @$_REQUEST['-wizard'] == 'Wizard1' ){
header("Location: ");
exit;
}
}

function block__after_new_record_form(){
//function block__after_edit_form(){
if ( @$_REQUEST['-wizard'] != 'Wizard1' ){
$app =& Dataface_Application::getInstance();
$record =& $app->getRecord();
$bid =& $record->getValue('bid');
echo '';
echo '';
echo '';
}
}

This gives me the button called "Speichern und weiter zu Neues Fahrzeug" (which means "Continue with new vehicle") and if I fill in the fields and use it will lead me to table vehicles. Unfortunately it does not save anything in tables betriebe. If I look at the URL i can read something like:

http://www.mydomain.de/pathtomyapp/index.php?-table=vehicles&-action=new&-wizard=Wizard1

I am not sure either what you meant with 'existing_betriebe_form' in the JavaScript onclick event handler, so I put "Dataface_New_Record.html" there.

So how to get the new record in tables betriebe saved first and second maintain the id of this new record over step 2 (fill in new record into table vehicles, keep the id of this new record also) until step 3 which is to fill in a new related record into tables umruest with both the maintained ids from tables betriebe and vehicles).

Don't really know how to use the wizard thing correctly?

Thank you

Markus
Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm

Previous

Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 41 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved