Keyword

K2 Clears Extra Fields when editing article at Front end

  • Alexandr Kustov
  • Alexandr Kustov's Avatar Topic Author
  • Offline
  • New Member
More
6 years 2 weeks ago #167469 by Alexandr Kustov
If the article has extra fields and global k2 front edit settings is set to not display extra fields tab, then all extra fields flushes after editing it from front end

A possible solution:
1. Wrap a handler into if case
\administrator\components\com_k2\models\item.php 783
        if ($params->get('showExtraFieldsTab') || $application->isAdmin()) {
          $row->extra_fields = json_encode($objects);

          require_once(JPATH_COMPONENT_ADMINISTRATOR.'/models/extrafield.php');
          $extraFieldModel = K2Model::getInstance('ExtraField', 'K2Model');
          $row->extra_fields_search = '';

          foreach ($objects as $object)
          {
              $row->extra_fields_search .= $extraFieldModel->getSearchValue($object->id, $object->value);
              $row->extra_fields_search .= ' ';
          }

        }

2. Check if extra fields are empty at db update
\administrator\components\com_k2\models\item.php 909
        if (!is_null($row->extra_fields))
		{
        	$query .= " extra_fields = ".$db->Quote($row->extra_fields).", extra_fields_search = ".$db->Quote($row->extra_fields_search)." , ";
        }
        
        $query .= "published = ".$db->Quote($row->published)." WHERE id = ".$row->id;
        $db->setQuery($query);

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 2 weeks ago #167497 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 Clears Extra Fields when editing article at Front end
Hello there and thank you for reporting this.
A Pull Request is always welcome and we can evaluate the code github.com/getk2/k2

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum