Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

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

  • madaura
  • madaura's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 35
  • Thank you received: 3
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,

Please Log in or Create an account to join the conversation.

Last edit: by admin.

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

  • BTB300
  • BTB300's Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 415
  • Thank you received: 132
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
The following user(s) said Thank You: madaura

Please Log in or Create an account to join the conversation.

Last edit: by BTB300.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
@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

Please Log in or Create an account to join the conversation.

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

  • madaura
  • madaura's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 35
  • Thank you received: 3
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,

:)

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

Please Log in or Create an account to join the conversation.

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

  • madaura
  • madaura's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 35
  • Thank you received: 3
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!

Please Log in or Create an account to join the conversation.

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

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

Please Log in or Create an account to join the conversation.

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.

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

Please Log in or Create an account to join the conversation.

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

  • BTB300
  • BTB300's Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 415
  • Thank you received: 132
When jquery intergation was added to the Cook environment I started here docs.jquery.com/Tutorials

Please Log in or Create an account to join the conversation.

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

  • madaura
  • madaura's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 35
  • Thank you received: 3
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!

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.085 seconds

For starters it's just so easy to design an app in a way that I'm used to i.e. database first then views followed by customization. The fork system is pure brilliance from a developer standpoint as I can override things and still add and update my projects with minimal effort! Truly amazing to be able to build components in Joomla using incremental refinement without having to do everything by hand. Thanks for the great tool! I am so much more productive now than ever and I can't imagine building components any other way!!!!
Dave (Forum)

Get Started