Welcome, Guest
Username: Password: Remember me

TOPIC: Adding custom logic to a Cook form

Adding custom logic to a Cook form 20 Aug 2012 19:18 #3215

  • madaura
  • madaura's Avatar
  • Offline
  • Junior Member
  • Posts: 35
  • Thank you received: 3
  • Karma: 0
Hi,

I have already created a form, BUT I need to add some logic in order to add data according with the content of some previous fields to keep the consistency of the info,

For instance,

Field 1. name:
Field 2. Any studies? (y/n)

if Field 2 = yes
Field 3. Name of field of study:
Field 4. Are you certified: (y/n)

if Field 4 = yes
Field 5. Place where get the certificate:
end-if

end-if

Field 6. Current activity:

etc.

Is this possible to do inside Cook? if not, could you let me know the way to do that?

Thanks a lot in advance!

Best,
Last Edit: 21 Aug 2012 08:09 by admin.
The administrator has disabled public write access.

Re: Adding custom logic to a Cook form 20 Aug 2012 23:44 #3216

  • BTB300
  • BTB300's Avatar
  • Online
  • Moderator
  • Posts: 414
  • Thank you received: 130
  • Karma: 46
Outside cook

in the layout you could use
<?php if (isset($item->field1)):?>
	<label for="field2">
		<?php echo JText::_( "MY_FIELD1_LABEL" ); ?> :
	</label>
	<label for="field3">
		<?php echo JText::_( "MY_FIELD2_LABEL" ); ?> :
	</label>
<?php endif; ?>

- Define Label Values in the Language file en-GB.com_yourcomponentname.ini
Last Edit: 20 Aug 2012 23:47 by BTB300.
The administrator has disabled public write access.
The following user(s) said Thank You: madaura

Re: Adding custom logic to a Cook form 21 Aug 2012 08:09 #3219

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
@BTB300

This works only once the form is saved.

Better to use Javascript for that.

jQuery is your friend. ;-)
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Adding custom logic to a Cook form 21 Aug 2012 13:26 #3234

  • madaura
  • madaura's Avatar
  • Offline
  • Junior Member
  • Posts: 35
  • Thank you received: 3
  • Karma: 0
I see...

By now I'm going to purchase my Cook subscription, download the component and install it. I just started to use Cook the last week and it's really great, but of course I have a lot to learn..

Thanks for your recommendations,

:)
The administrator has disabled public write access.

Re: Adding custom logic to a Cook form 21 Aug 2012 13:41 #3236

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Great.

Don't worry, the community will help you. Here, or on joomla.org, it is not a big deal to understand how Joomla works because the community is big.

Enjoy.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Adding custom logic to a Cook form 23 Aug 2012 23:03 #3274

  • madaura
  • madaura's Avatar
  • Offline
  • Junior Member
  • Posts: 35
  • Thank you received: 3
  • Karma: 0
Like Admins said, the BTB300 solution works only when the form is saved, so I'd like to try using jQuery but I have no idea how use it. Could you give me please some indications to start?

Thanks!
The administrator has disabled public write access.

Re: Adding custom logic to a Cook form 24 Aug 2012 05:00 #3277

Yes, that would be great, I also would like to know what to do to get started with JQuery
herman
The administrator has disabled public write access.

Re: Adding custom logic to a Cook form 24 Aug 2012 08:18 #3283

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Did some of you know something about MooTools of Prototype frameworks ?

jQuery is simply extending the native javascript functionalities.

I could say, do it in javascript !
But in our days, nobody is coding in JS without framework.

The basics :
var object = $('my_html_ID');
or
var object = jQuery('my_html_ID'); //for cross compatibility

Because '$' is a FUNCTION, very important to understand. And this function has been defined both in MooTools AND jQuery. So the conflict comes from that. Ok ?

If you are coding a long script, you may use the trick to be able to use the '$' function without problems. I show you and explain :
(function ($) {
// your code here
})(jQuery)

I explain :
'jQuery' function = '$' function

so, your call is inside a function receiving a parameter, the framework (jQuery function)

The source is the same than:
var mySource = function($)
{
	// Here the $ is a local var (no conflicts)
	// Note in this case, the $ var is a function (jQuery framework)
};

//Here the code is called
mySource(jQuery);	//No conflict, with the '$' function of MooTools

When you call only one line command, you still can use 'jQuery' instead of '$'

Well, if you understand this, you start with a good basis, and your code will always be compatible.

I cannot explain all jQuery here, but you will see, it is easy. Search for tutorials.
Because, it depends what you want to do...
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Adding custom logic to a Cook form 24 Aug 2012 16:48 #3290

Thanx for giving us such good explanation and thanx for your time. I appraciated very much.
This is all quite new for me, I come for a totaly different environment, IBM mainframes, but I like this all very much, and I like it very much to that people here are so helpfull and so much sharing all there knowledge.
The administrator has disabled public write access.

Re: Adding custom logic to a Cook form 24 Aug 2012 17:18 #3291

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
You are welcome !
I like it very much to that people here are so helpfull and so much sharing all there knowledge.

Open Source ;-)

And Joomla is the only Open Source CMS not backed on a company business.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Adding custom logic to a Cook form 25 Aug 2012 13:21 #3293

  • BTB300
  • BTB300's Avatar
  • Online
  • Moderator
  • Posts: 414
  • Thank you received: 130
  • Karma: 46
When jquery intergation was added to the Cook environment I started here docs.jquery.com/Tutorials
The administrator has disabled public write access.

Re: Adding custom logic to a Cook form 25 Aug 2012 17:46 #3295

  • madaura
  • madaura's Avatar
  • Offline
  • Junior Member
  • Posts: 35
  • Thank you received: 3
  • Karma: 0
I'm agree with herman,

I'm new on this too, but I really appreciate your time and the detail of your explanations Admin, right now I don't understand very well what you try to explain, but thanks to BTB300 I have where to start!
The administrator has disabled public write access.
Time to create page: 0.134 seconds

Get Started