0

I am currently building a custom Component in Joomla 3 that allows users to search for a sports club by postcode using an Ajax form on the front end. I have all this functionality working and am now currently working on the backend of the component (in the admin). This section needs to alow admins to add and delete sports clubs amongst other things.

I am not overly experienced with building custom Joomla components but have a good working knowledge of MVC but have encountered some issues.

The component uses a view called 'Posctodes' as the default view which itself contains a dropdown menu of all the current sports clubs which allows a user to choose a club, hit submit and be taken to an edit page to change details about that club. This is where I am having the problem. I want to make a seperate view called 'editform' which a user would be taken to they have chosen a club to edit. I am unsure as to how to go about this within the Joomla framework.

Here is my code for the component so far:

Controller ofr the component (admin/components/com_postcode/controller.php):

<?php
defined('_JEXEC') or die;

class PostcodeController extends JControllerLegacy {

    protected $default_view = 'postcodes';

    public function display($cacheable = false) {           

        $view = $this->input->get('view', 'postcodes');
        $layout= $this->input->get('layout', 'postcodes');
        $id     = $this->input->getInt('id');

        return parent::display($cacheable);
    }
}

?>

The view.html.php file for the postcode view (admin/components/com_postcode/views/postcodes/view.html.php):

<?php
defined('_JEXEC') or die;

class PostcodeViewPostcodes extends JViewLegacy {

    public function display($tpl = null) {
        $clubs = $this->get('Clubs');
        $this->clubs = array();
        foreach($clubs as $club) {
            $this->clubs[] = array(
                'club_id'         =>    $club['club_id'],
                'name'            =>    $club['name'],
                'postcode'        =>    $club['postcode'],
                'link'            =>    $club['link'],
                'description'     =>    $club['club_id'],
                'image'           =>    $club['club_id'],
                'address'         =>    $club['club_id']
            );
        }
        $pagination = $this->get('Pagination');

        $this->items = $items;
        $this->pagination = $pagination;

        parent::display($tpl);
    }

}   

?>

And the view file (admin/components/com_postcode/views/postcodes/tmpl/default.php):

<div class="row-fluid">
<div id="filter-bar" class="btn-toolbar">
    <a class="btn" href="">Clubs</a>
    <a class="btn" href="">Postcodes</a>
</div>
<div class="span2">view

</div>
<div class="postcode_admin span10">
    <h3>Postcode Search Component</h3>      
    <form action="<?php echo JRoute::_('index.php?option=com_users&view=clubedit');?>" method="post" name="postcodeForm" id="postcodeForm">
        <select name="clubs" id="clubFilter">
            <option value="">-- Please select --</option>
            <?php foreach($this->clubs as $club) { ?>
                <option value="<?php echo $club['club_id']; ?>"><?php echo $club['name']; ?></option>
            <?php } ?>
        </select>
        <input type="submit" name="submit" id="submit" value="Submit" />
    </form> 

    <div class="club_information">

    </div>
</div>

As you can see from the 'default.php' file I am telling the form to submit to the 'clubedit ' view but it doesn't. I know I am missing something here but there is not a lot of documentation on Joomla 3 components online. Can anyone shed any light on this?

Thanks!!

tereško
  • 58,060
  • 25
  • 98
  • 150
James
  • 2,800
  • 7
  • 45
  • 81
  • What do you mean by Joomla does not submit the clubedit view? Submit is happening, but you are redirected to another view? – Dmitrijs Rekuns Mar 28 '13 at 18:25
  • 2
    Try using one of the 2.5 tutorials to help you, not too much has changed between the two versions. – Michael Mar 29 '13 at 02:18
  • I don't get it... your component is `com_postcode`? and yet you're submitting to `com_users` with a view of `clubedit` which is a custom view you've added to the core `com_users`? – Craig Mar 29 '13 at 03:53

0 Answers0