How does Catchall exactly work?
Posted: 03 September 2010 02:06 AM   [ Ignore ]
Wallflower
Avatar
Rank
Total Posts:  30
Joined  2010-08-10

I am confussed as to how the catchall field works. In the docs: http://barrettnewton.com/safecracker/user_guide/#section_tutorials_examples

{customer_details} is the field with the catchall fieldtype. What is {contact_info} and the things in square brackets?

Profile
 
 
Posted: 03 September 2010 02:13 AM   [ Ignore ]   [ # 1 ]
Absolute Heartthrob!
Avatar
RankRankRankRankRank
Total Posts:  10369
Joined  2008-09-29

If you have a catchall field called {customer_details}

you could throw anything you want at it in a form like so:

<input name="customer_details[contact_info][address]" />
<
input name="customer_details[contact_info][name]" />
<
input name="customer_details[company_details][printouts]" />
<
input name="customer_details[company_details][associates]" />
<
input name="customer_details[company_name]" /> 

Catchall will add the necessary rows and columns on the backend.
Then output like this:

{customer_details}
    {contact_info}
        Name
{name}<br /> 
        
Address{address}<br /> 
        
City{city}<br /> 
        
State{state}<br /> 
        
Zip{zip}<br />
    
{/contact_info}

    {company_details}
        Associates
{associates}<br /> 
        
Printouts{printouts}<br /> 
    
{/company_details}

    Company Name
{company_name}
{
/customer_details} 

If you try it once, you’ll get the use/value.

 Signature 
Profile
 
 
Posted: 03 September 2010 02:15 AM   [ Ignore ]   [ # 2 ]
Wallflower
Avatar
Rank
Total Posts:  30
Joined  2010-08-10

I found this: http://barrettnewton.com/safecracker/user_guide/examples/contact_form/
and got it to work. The other example has a field within a field {customer_details} {contact_info}, is this correct?

I understand about the square bracket array data now. Pretty handy. Glad I just created 80 fields before I messed around with that smile oh wait :(

Profile
 
 
Posted: 03 September 2010 02:15 AM   [ Ignore ]   [ # 3 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

It takes in nested arrays—one or two levels deep. Here’s what it looks like in the control panel:

Profile
 
 
Posted: 03 September 2010 02:28 AM   [ Ignore ]   [ # 4 ]
Absolute Heartthrob!
Avatar
RankRankRankRankRank
Total Posts:  10369
Joined  2008-09-29

The other example was a bit confusing. I revised it to just be a simple data entry example. It was really a more advanced ENTRY/EDIT form, rather than a simple ENTRY example.

Glad I just created 80 fields before I messed around with that oh wait :(

Hah, yeah. Fields are definitely more handy.. but take longer to set up. The catchall is a great quick way to get going.

 Signature 
Profile