function save in controller.php, for blocks

I'm new to PHP and can't wrap my head around this or find any helpful documentation, so a point in the right direction would be great.

I'm trying to build a block with fields that draw from two libraries. "Choose image" will draw from the image library, and "Choose link" will draw from the internal link gallery (i.e., "site/path/to/file/index.php").

I kind of Frankensteined the block out of two of Concrete's premade blocks.

In controller.php, there is a conflict between these two:

function save($data) {
         $content = $this->translateTo($data['content']);
         $args['content'] = $content;


public function save($args) {      
         $args['fOnstateID'] = ($args['fOnstateID'] != '') ? $args['fOnstateID'] : 0;
         $args['fID'] = ($args['fID'] != '') ? $args['fID'] : 0;

Is there a way to make these two play well together? Thanks for any help.

View Replies: View Best Answer
Tony replied on at Permalink Best Answer Reply
public function save($args) {
  $args['fOnstateID'] = ($args['fOnstateID'] != '') ? $args['fOnstateID'] : 0;
  $args['fID'] = ($args['fID'] != '') ? $args['fID'] : 0;
  $content = $this->translateTo($args['content']);
  $args['content'] = $content;
andrew replied on at Permalink Reply
Yeah, Tony is right. Just take both bodies of the save() functions and combine them into the one.
stephmars replied on at Permalink Reply
I will be committing this to memory immediately. A thousand times thank you, sir, for your help. It works like a charm. You've saved what was my rapidly breaking heart.
ScottC replied on at Permalink Reply
well for those that are reading this, hopefully due to the title of this post, you will be, any function called via $this->action('save_crm_data') assuming you are using post data(form)

The controller function needs to be named

action_save_crm_data otherwise it won't match up the post action and the data won't be committed.

This stumped me for a few minutes a week ago, just wanted to share.