Jump to content

Combine InputfieldSelector with MarkupAdminDataTable


Orkun
 Share

Recommended Posts

I've created a custom process module, which the user can manage form-entries. In my executeEntries function, I've created a custom InputfieldSelector(should serve as real-time-search) and a custom MarkupAdminDataTable(serves as Resulttable) which holds the entries. How is it possible to combine the InputfieldSelector with the MarkupAdminDataTable?

  • How can I get the selector from the InputfieldSelector?
  • How can I convince the MarkupAdminDataTable, that he uses the new selector from the InputfieldSelector every time when I change the filters in the InputfieldSelector?

public function executeEntries:

public function executeEntries(){
        $this->fuel->breadcrumbs->add(new Breadcrumb('./', 'Event-Manager'));
        $this->fuel->breadcrumbs->add(new Breadcrumb('./', 'Dashboard'));
        $this->fuel->set('processHeadline', 'Formulareinträge Event-Formular');

	$form = $this->modules->get("InputfieldForm");
        $form->method = "post";
        $form->attr('id',$this->className());

        $fieldset = $this->modules->get("InputfieldFieldset");
        $fieldset->label = "Suche";
        $fieldset->collapsed = Inputfield::collapsedNo;

        $field = $this->modules->get("InputfieldSelector");
       	$field->label = "Filter";
       	$field->attr("name+id", "filters");
       	$field->setAttribute("value", "template=50");
       	$allowedFields = array();
       	$formtemplate = $this->templates->get("name=form-submission");
       	foreach ($formtemplate->fields as $fieldN) {
       		$allowedFields[] = $fieldN->name;
       	}
       	array_push($allowedFields, "template");
       	$field->limitFields = $allowedFields;
       	$fieldset->add($field);
		

	$entries = $this->pages->find("template=form-submission");

	$table = $this->modules->get("MarkupAdminDataTable");
	$table->headerRow( array("Name", "Erstellt", "Aktionen") );
	$table->setEncodeEntities(false);
	$table->action(array('Als Excel exportieren' => "./export"));
	foreach($entries as $entry){
          $data = array(
		$entry->title,
		date("d.m.Y H:i:s", $entry->created),
		"<a href='showentry?id=$entry->id'>Details anzeigen</a> | 
                 <a href='./editentry?id=$entry->id'>Bearbeiten</a>",
           );
          $table->row($data);
	 }        

	$preview = $this->modules->get("InputfieldMarkup");
        $preview->value .= "<h2>" . $this->_("Formulareinträge Event-Formular") . "</h2>";
        $entriesLimit = 20;
        $entriesOffset = ($this->input->pageNum - 1) * $entriesLimit;
        $entriesTotal = count($entries);
        $preview->value .= sprintf($this->_("Anzahl der Einträge: %s"), $entriesTotal);
        $preview->value .= " | ";
        $preview->value .= sprintf($this->_("Anzahl pro Seite: %s"), $entriesLimit) . 
        "<br/>";
	$preview->value .= $table->render();
	$pagination = new PageArray();
        $pagination->setTotal($entriesTotal);
        $pagination->setLimit($entriesLimit);
        $pagination->setStart($entriesOffset);
        $preview->value .= $pagination->renderPager();

        $form->add($fieldset);
	$form->add($preview);

	return $form->render();
}

How the Interface looks like:

post-3125-0-77594100-1453285056_thumb.pn

Link to comment
Share on other sites

InputfieldSelect is a form inputfield like any others, so if you submit a form with the inputfield in it, the selector will be sent. You can then use this selector in the module to select the pages. There's no such thing as a prebuild ajax solution to update without an pagerefresh.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...