Jump to content

Recommended Posts

  • 6 months later...
Posted

Hi @arjen

Does the module work without issues with PW 3.x? I'm planning to use your fork: https://github.com/arjenblokzijl/FieldtypeDecimal

I'm wondering if you are willing to add PW namespace so that it does not need the compiler anymore (people can still download old version for PW 2.x from GitHub). Also, you might want to take over maintenance as @sforsman does not seem to be doing it anymore. What do you think?

Posted

We are using it on one ProcessWire install which is used heavily. We have around 20 Decimal fields with over 200k+ pages with all kinds of automated calculations (thanks @Martijn Geerts). Still working fine :P...

I haven't tried it on other installs, so I would really like to see @sforsman giving his blessing.

You might want to test it out yourself. If it works for you I can cover the maintenance, no worries.

  • Like 2
Posted (edited)

Thanks for your detailed answer!

14 minutes ago, arjen said:

You might want to test it out yourself. If it works for you I can cover the maintenance, no worries.

You are being very generous, thank you! In the meantime I did install your fork and did not run into any issues. This filed should be in the core, btw...

Let's see what @sforsman has to say. He has not logged in for a while, but one never knows :)

Edited by szabesz
He has not logged in for a while: not true... sorry
  • Thanks 1
  • 1 month later...
  • 1 month later...
Posted

@szabesz any progress on this? Decimal is a fundamental data type of most dialects of SQL for the reasons that have been outlined in this thread. Over three years and it's still not in the core seems to be a rather long time for what should be a standard fieldtype.

It's great someone has done a third-party module, but it would be nice if it were in the core.

  • Like 2
Posted

I'm not aware of any additional work on this. Please give it a thumbs up at my GitHub request and you might also want to express why. New features are often added to ProcessWire when it is asked by lots of us...

  • Like 2
  • 11 months later...
  • 3 weeks later...
Posted
On 12/10/2018 at 2:04 PM, NorbertH said:

How can i convert a float field to decimal , decimal does not show up in select list for change fieldtype ?

In admin.php file :

/**
 * Hook :
 *      Add FieldtypeDecimal to compatible fieldtypes of
 *      a FieldtypeFloat when a superuser need to change the type
 *      of a float field.
 *
 *      https://modules.processwire.com/modules/fieldtype-decimal/
 *		https://processwire.com/talk/topic/7542-development-fieldtypefloat-fieldtypedecimal/
 *
 */
$wire->addHookAfter('FieldtypeFloat::getCompatibleFieldtypes', function($event) {
    if(!$this->modules->isInstalled('FieldtypeDecimal') || !$this->user->isSuperuser()) return;
    $return = $event->return;
    $return->set('FieldtypeDecimal', $this->modules->get('FieldtypeDecimal'));
    $event->return = $return;
});

 

  • Like 3
Posted

Or change it in the database - via the link to Adminer in the RequestInfo panel in Tracy is a nice shortcut, but however you get there is fine.

rw1XrkEkv0.thumb.gif.849abbdbfd3c803a6b1eaf1be327868d.gif

  • Like 4
  • 6 months later...
Posted

Would it be possible to set up a number spinner with the currently advised fieldtype (FieldtypeDecimal/Float)? I can see plenty of situations where that would be helpful. It is not too far off the mark, either, for we already have to set the precision for a "float" (actually a fixed-point number). Suppose I set a precision value k. Then the default value of the spinner step would be 10^-k. However, it could be changed to any number with the precision k. So, for example, I could have a float with the precision 2 and the spinner step set to 0.25. In my experience, while education and leave hours are reported as decimals, they are doled out only in quarter- or half-hours. Thank you! 

Posted

@stuartsa, you can achieve a step setting for InputfieldInteger / InputfieldFloat / InputfieldDecimal by a couple of hooks in /site/ready.php:

// Add a step setting to InputfieldInteger / InputfieldFloat / InputfieldDecimal
$wire->addHookAfter('Inputfield(className=InputfieldInteger|InputfieldFloat|InputfieldDecimal)::getConfigInputfields', function(HookEvent $event) {
	$inputfield = $event->object;
	$field = $inputfield->hasField;
	if(!$field) return;
	/* @var InputfieldWrapper $wrapper */
	$wrapper = $event->return;

	/* @var InputfieldText $f */
	$f = $event->wire('modules')->InputfieldText;
	$f->name = 'step';
	$f->label = 'Step';
	$f->value = $field->step;
	$f->showIf = 'inputType=number';
	$wrapper->add($f);
});

// Add step attribute to InputfieldInteger / InputfieldFloat / InputfieldDecimal
$wire->addHookBefore('Inputfield(className=InputfieldInteger|InputfieldFloat|InputfieldDecimal)::render', function(HookEvent $event) {
	/* @var Inputfield $inputfield */
	$inputfield = $event->object;
	$field = $inputfield->hasField;
	if(!$field || !$field->step || $field->inputType !== 'number') return;
	$inputfield->attr('step', $field->step);
});

2019-06-25_201717.png.5cf9318b78139db65c650eb7f7c6e50c.png

step.gif.d557ea46e833bad0599f6b23c59f438d.gif

  • Like 3

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
×
×
  • Create New...