Jump to content
ryan

Events Fieldtype & Inputfield (How to make a table Fieldtype/Inputfield)

Recommended Posts

@robsns,

Welcome to ProcessWire and the forums.

Are you saying that you have a single (1) page with a custom field (based on FieldtypeEvents) that has ~18 columns and there's 6000 event entries (rows), i.e.., 6000x18 in total? Difficult to give a specific answer to your question since not clear why you have to have all these courses in 1 page. There could be other options, e.g. using a Process Module, or separating those 6000 courses into different groups, etc. If you want to discuss further, please start a new topic (since your question is not really related to FieldtypeEvents but a different custom module) and we'll take it from there

Share this post


Link to post
Share on other sites

hi,

how can I add pageing support for the input-table? my customer already has more than 100 events.

thx in advance

Share this post


Link to post
Share on other sites
On 11/22/2016 at 3:15 PM, rouge said:

hi,

how can I add pageing support for the input-table? my customer already has more than 100 events.

thx in advance

I would suggest taking a look at Profields Table (http://processwire.com/api/modules/profields/table/) which now supports pagination. Actually, technically it is the PW core that now supports it and the Table field is the first to implement it. So technically you could add it to this custom Events fieldtype, but the Table field would make your life much easier.

  • Like 1

Share this post


Link to post
Share on other sites

I have just downloaded it and seems very good and userfriendly. And the user interface is damn perfect too. And apart from all front end is much faster and effective.

Share this post


Link to post
Share on other sites
On 4/27/2018 at 12:17 PM, rareyush said:

I am using this module is there anyway to add time field as well in this module ?

Do you mean a separate field for time? Not out of the box, no. You'd have to edit the source code. If you can be a bit more specific about your needs, we can rustle up something for you.

Share this post


Link to post
Share on other sites
6 hours ago, kongondo said:

Do you mean a separate field for time? Not out of the box, no. You'd have to edit the source code. If you can be a bit more specific about your needs, we can rustle up something for you.

here is the link for my thread where I described my prolem

 

Share this post


Link to post
Share on other sites

How is it possible choose time with the datetime picker? It is possible to select the date, but not the time....
I´ve looked and tried a few things... but nothing  did work...

Share this post


Link to post
Share on other sites

A problem occured...
this code does not work, the updated event field is not saved (but saving works, the title is saved)
and the sleepvalue method isn´t called

$page->title = "custom title";
foreach($page->events as $event){
  $event->location ="new location";
  $event->notes    ="new notes";
}
echo "now we save...";
$page->save();

but when I add an event to the field array the new event is saved AND the fields are stored - this code works:

$event = new Event();
$event->date = "1979-10-12 00:42:00";
$event->location = "Vogsphere";
$event->notes = "The homeworld of the Vogons";
$page->events->add($event);

foreach($page->events as $event){
  $event->location ="new location";
  $event->notes    ="new notes";
}
echo "now we save...";
$page->save();

 

Share this post


Link to post
Share on other sites

I have a solution: in the EventArray I wrote this:

	public function setTrackChange(){
		parent::trackChange('value');
	}

it works now with this modification, I don´t know if there is a better way
$page->events->setTrackChange();
$page->save();

Share this post


Link to post
Share on other sites

This is a small tutorial...
If you want add another field to this fieldtype... first
in FieldtypeEvents.module in getDatabaseSchema() add a line that suit your needs, so your new field gets stored to the database

		$schema['newValue'] = 'TINYTEXT NOT NULL';

try if you can install the module and add a field to a template and check if it works like before

add the property to the constructor in Events.php

        $this->set('newValue', "");

then modify set() and get() so you can modify your new property...

now try in your template,´if you can modify and output the new property

foreach($page->events as $event){
	$event->newValue = "hello new value";
 	echo "yes it works, we we welcome the new value: ". $event->newValue."<br>";
}

if this works properly then go back to FieldtyeEvents.module:

add this line in __wakeupValue() to the foreach loop

$event->newValue	= $v['newValue']; 

and in _sleepValue()

'newValue' 	=> $event->newValue, 

in file InputfieldEvents.module  in renderRow() method

make sure, a $newValue variable gets gets sanitized from

$newValue = $this->sanitizer->entities($event->newValue); 

change

$out = "
			<tr class='Event$cnt $class'>
				<td><a href='#' class='EventClone'><span class='ui-icon ui-icon-copy'></span></a></td>
				<td><input type='text' name='{$name}_date[]' value='$date' class='datepicker' /></td>
				<td><input type='text' name='{$name}_newValue[]' value='$_newValue'   /></td> //add this line

add your field in __render()
 

		<table class='InputfieldEvents'>
			<thead>
			<tr class=''>
				<th class='EventClone'>&nbsp;</th>
				<th class='EventDate'>Date</th>
                <th class='EventDate'>newValue</th>   //I´ve chosen EventDate class because its narrow

and in __processInput()

			$event->newValue = $input->{"{$name}_newValue"}[$cnt];

I hope I didn´t forget anything, good luck!

  • Like 3

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...