Problem with Developing an MVC Component/Adding a front-end form

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Post Reply
RemiAdem45
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Sat Aug 18, 2018 10:11 am

Problem with Developing an MVC Component/Adding a front-end form

Post by RemiAdem45 » Mon Nov 11, 2019 2:55 pm

Hello

I am following this tutorial https://docs.joomla.org/J3.x:Developing ... nd_form/fr and I have a problem.

The form part of this component works only when I am connected to my web site as a super user.

Any idea why?

I am using joomla 3.9.13

Thanks for answer
Last edited by toivo on Tue Nov 12, 2019 5:14 am, edited 1 time in total.
Reason: mod note: moved from 3.x Extensions

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22347
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: Problem with Developing an MVC Component/Adding a front-end form

Post by pe7er » Mon Nov 11, 2019 3:07 pm

You've probably encountered an issue with permissions.

The example code checks if the user has "create" right to create new items in that component:

Code: Select all

if (!($this->canDo->get('core.create')))
Your Super User has the rights to create new items. But probably other groups have not.

You've to configure the permissions of your component, e.g. : give a group ("registered"?) the permission to create new items. Do you have a access.xml file in the back-end of your component? That is used for configuring the permissions in your component.
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content

smpleader
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 100
Joined: Thu Jun 21, 2012 7:17 am

Re: Problem with Developing an MVC Component/Adding a front-end form

Post by smpleader » Tue Nov 12, 2019 4:43 am

When you create a component, did you assign form-view into a menu item ?
If do, check permission for access menu item.
If not, check permission with your access in view.html.php, which define "cando"
And, it's better to have more details like screenshot or error message, so we could send the right direction.
When developing, it's good to turn on Debug mode ON, so you could find more details of your bug.

RemiAdem45
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Sat Aug 18, 2018 10:11 am

Re: Problem with Developing an MVC Component/Adding a front-end form

Post by RemiAdem45 » Tue Nov 12, 2019 7:55 pm

Yes I have an access.xml file
Here is the content:

Code: Select all

?xml version="1.0" encoding="utf-8" ?>
<access component="com_helloworld">
	<section name="component">
		<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
		<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
		<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />
		<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
		<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
	</section>
	<section name="category">
		<action name="core.create" title="JACTION_CREATE" description="COM_CATEGORIES_ACCESS_CREATE_DESC" />
		<action name="core.delete" title="JACTION_DELETE" description="COM_CATEGORIES_ACCESS_DELETE_DESC" />
		<action name="core.edit" title="JACTION_EDIT" description="COM_CATEGORIES_ACCESS_EDIT_DESC" />
		<action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_CATEGORIES_ACCESS_EDITSTATE_DESC" />
		<action name="core.edit.own" title="JACTION_EDITOWN" description="COM_CATEGORIES_ACCESS_EDITOWN_DESC" />
	</section>
	<section name="message">
		<action name="core.delete" title="JACTION_DELETE" description="COM_HELLOWORLD_ACCESS_DELETE_DESC" />
		<action name="core.edit" title="JACTION_EDIT" description="COM_HELLOWORLD_ACCESS_EDIT_DESC" />
	</section>
</access>
But I don't know how to had permission for registred members for example

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22347
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: Problem with Developing an MVC Component/Adding a front-end form

Post by pe7er » Tue Nov 12, 2019 9:36 pm

Is your component called com_helloworld ?

Info about how to set permissions for your component + User Group:
https://docs.joomla.org/J3.x:Access_Con ... t_Tutorial
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content

RemiAdem45
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Sat Aug 18, 2018 10:11 am

Re: Problem with Developing an MVC Component/Adding a front-end form

Post by RemiAdem45 » Sun Nov 24, 2019 11:32 am

Yes my component is called com_helloworld it's the one in the tutorial.
I have read the tutorial about how to set permissions and I manage to give access to the form to every one by changing the rights of the component in the configuration part.
But my question is what I have to do in my component code to remove this access limitation.
I mean in the future I make a component similar but as soon I install it I like to not have to change permissions after installation. I guess I have to modify the access.xml file but I don't see how :(

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22347
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: Problem with Developing an MVC Component/Adding a front-end form

Post by pe7er » Sun Nov 24, 2019 11:57 am

RemiAdem45 wrote:
Sun Nov 24, 2019 11:32 am
But my question is what I have to do in my component code to remove this access limitation.
Remove the ACL checks in the view.html.php:

Code: Select all

if (!($this->canDo->get('core.create')))
and maybe in other parts of the component.
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 26191
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: Problem with Developing an MVC Component/Adding a front-end form

Post by Per Yngve Berg » Sun Nov 24, 2019 12:43 pm

Setting the Default Access Permissions in the Installation Script is the way to go.


Post Reply

Return to “Joomla! 3.x Coding”