Actions

J2.5 talk

Difference between revisions of "Developing a MVC Component/Adding backend actions"

From Joomla! Documentation

(Joomla 3.x)
(Joomla 3.x: clarification - works, just missed one small thing)
 
(One intermediate revision by one user not shown)
Line 29: Line 29:
 
:This sounds like a bug of some kind - I'd check you don't have php errors on the page! The button itself should be called exactly the same way in 3.x as in 2.5!!
 
:This sounds like a bug of some kind - I'd check you don't have php errors on the page! The button itself should be called exactly the same way in 3.x as in 2.5!!
 
:Kind Regards,
 
:Kind Regards,
:George
+
:George --[[User:Wilsonge|Wilsonge]] ([[User talk:Wilsonge|talk]]) 19:34, 4 June 2013 (CDT)
 +
 
 +
::Thanks for the quick answer! Turns out I had missed one small detail: The form has to have name '''and id''' of adminForm. Somehow I had used a different ID, and under Joomla 2.5 it still had worked, but not on J3.
 +
::With that id set correctly, it works as well on J3! Weirdest thing is, I checked in com_banners component, and that doesn't seem to use the adminForm id as well, but it still works there... no idea how they do it, but I don't care now as long as it works for me ;).
 +
:: Thanks and so long,
 +
:: [[User:Munchkin|Munchkin]] ([[User talk:Munchkin|talk]]) 15:00, 5 June 2013 (CDT)

Latest revision as of 14:00, 5 June 2013

It's not clear to me where the word "helloworld" refers to in these examples. Can you please clarify when 'helloworld' refers to the component,controller,model,table,view or form? While following this, I've changed the name of my component, and when running this I get a 'call to member function getTable() on non-object'. It seems that I used the wrong name somewhere, but I have no idea where.

We're also introducing JForms and JFields. These are powerful and important, and warrant some richer explanation.

Contents

Attention!

There is a change in /admin/views/helloworlds/tmpl/default_body.php that isnt mentioned on this page but is present in the archive file.

Model subtlety

Note that the model loaded in the getModel function by the HelloWorlds controller (admin/controllers/helloworlds.php) is NOT the HelloWorlds model; it is instead the HelloWorld model. The HelloWorlds model (HelloWorldModelHelloWorlds) extends JModelList, which has no delete function. The HelloWorld model (HelloWorldModelHelloWorld) extends JModelAdmin, which has the delete function needed to delete items.

Naming confusion

I agree with the first user. helloworld is an abused word in the example. We could call the table greetings, so the models (greetings and greeting) and so on. Without using different and clear name the reader cannot understand the mechanism of the MVC pattern. There is also a lack of documentation, e.g. when we create the form in admin/models/forms/helloworld.xml we should give a link or something to possible values of the fields used.

+1 over here. Naming is too confusing: "HelloWorldControllerHelloWorlds and HelloWorldControllerHelloWorld have to be coded." oh come on, I can't believe there's no better example than "HelloWorld"
admin/controllers/helloworlds.php and
admin/controllers/helloworld.php files... That's just too much for me!
João Paulo Freire 17:54, 11 April 2012 (CDT)

Joomla 2.5

The counting of the checkboxes are not working any more in Joomla 2.5. Does someone have a solution to this?

Try...

 <input type="checkbox" name="checkall-toggle" value="" title="<?php echo JText::_('JGLOBAL_CHECK_ALL'); ?>" onclick="Joomla.checkAll(this)" />

... in the appropriate template. Cwinebrinner (talk) 22:23, 31 March 2013 (CDT)

Joomla 3.x

Anybody know what changes are required to this for Joomla 3.x? I've followed the tutorial and it seems to be working fine under Joomla 2.5, however under Joomla 3.1, the "Save and Close" and "Cancel"/"Close" Button on the details form just do nothing (clicking on them only gives a Javascript error: "TypeError: b is null"; and the form looks weird (there is still a bulletin point for all the list elements). Munchkin (talk) 17:28, 3 June 2013 (CDT)

Hi
This sounds like a bug of some kind - I'd check you don't have php errors on the page! The button itself should be called exactly the same way in 3.x as in 2.5!!
Kind Regards,
George --Wilsonge (talk) 19:34, 4 June 2013 (CDT)
Thanks for the quick answer! Turns out I had missed one small detail: The form has to have name and id of adminForm. Somehow I had used a different ID, and under Joomla 2.5 it still had worked, but not on J3.
With that id set correctly, it works as well on J3! Weirdest thing is, I checked in com_banners component, and that doesn't seem to use the adminForm id as well, but it still works there... no idea how they do it, but I don't care now as long as it works for me ;).
Thanks and so long,
Munchkin (talk) 15:00, 5 June 2013 (CDT)