protected function prepareFields($entry = false)
	{
		// if the fields have been defined separately for create and update, use that
		if (!isset($this->crud['fields']))
		{
			if (isset($this->crud['create_fields']))
			{
				$this->crud['fields'] = $this->crud['create_fields'];
			}
			elseif (isset($this->crud['update_fields']))
			{
				$this->crud['fields'] = $this->crud['update_fields'];
			}
		}

		// PREREQUISITES CHECK:
		// if the fields aren't set, trigger error
		if (!isset($this->crud['fields']))
		{
			abort(500, "The CRUD fields are not defined.");
		}

		// if the fields are defined as a string, transform it to a proper array
		if (!is_array($this->crud['fields']))
		{
			$current_fields_array = explode(",", $this->crud['fields']);
			$proper_fields_array = array();

			foreach ($current_fields_array as $key => $field) {
				$proper_fields_array[] = [
								'name' => $field,
								'label' => ucfirst($field), // TODO: also replace _ with space
								'type' => 'text' // TODO: choose different types of fields depending on the MySQL column type
							];
			}

			$this->crud['fields'] = $proper_fields_array;
		}

		// if no field type is defined, assume the "text" field type
		foreach ($this->crud['fields'] as $k => $field) {
				if (!isset($this->crud['fields'][$k]['type']))
					$this->crud['fields'][$k]['type'] = 'text';
			}

		// if an entry was passed, we're preparing for the update form, not create
		if ($entry) {
			// put the values in the same 'fields' variable
			$fields = $this->crud['fields'];

			foreach ($fields as $k => $field) {
				// set the value
				if (!isset($this->crud['fields'][$k]['value']))
				{
					$this->crud['fields'][$k]['value'] = $entry->$field['name'];
				}
			}

			// always have a hidden input for the entry id
			$this->crud['fields'][] = array(
												'name' => 'id',
												'value' => $entry->id,
												'type' => 'hidden'
											);
		}
	}